Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: new uWebsocket.js #578

Closed
ghost opened this issue May 9, 2019 · 8 comments
Closed

Question: new uWebsocket.js #578

ghost opened this issue May 9, 2019 · 8 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented May 9, 2019

Is it possible without big changes to use new maintained uWebsocket.js (link below) for polling & websocket transports? I'd like to learn from engine.io code and start coding support for it.

Or should I start from null and create new lib.

https://github.com/uNetworking/uWebSockets.js

uWebsocket.js has support for websocket & http handling as well and is much faster and lighter than ws and I guess has same speed as uws (same author) or even faster because of live maintaining

@shirtleton
Copy link

Thanks for bringing this up again @Kamil93.
This has been a topic of debate for a few months now with little to no movement on the issue.

#560

@ghost
Copy link
Author

ghost commented May 14, 2019

I guess if we don't want a lot of changes in eio, it's necessary to create wrappers:

  • class that emulate ws.Server class
  • wrapper for request object, because req from uws.js has short lifetime (only while executing callbacks) and eio stores sometimes request for later. Differences in methods&getters names are also the reasons.

An HttpRequest is stack allocated and only accessible during the callback invocation.
https://unetworking.github.io/uWebSockets.js/generated/interfaces/httprequest.html

This was referenced May 17, 2019
@darrachequesne
Copy link
Member

You can also take a look at eiows, which is a fork of the uws package.

Instructions here: https://socket.io/docs/server-installation/#Other-WebSocket-server-implementations

@darrachequesne darrachequesne added the question Further information is requested label Oct 5, 2020
@darrachequesne
Copy link
Member

Update: I'm working on this, binding to a uWebsocket.js server sounds really promising in terms of performance.

@md-seb
Copy link

md-seb commented Oct 28, 2021

Update: I'm working on this, binding to a uWebsocket.js server sounds really promising in terms of performance.

@darrachequesne any success?

I noticed that there are no prebuilt binaries for node 16:

Error: This version: darwin_x64_93 of µWS is not compatible with your Node.js build:Error: Cannot find module 'uws.js/uws_darwin_x64_93.node

uWebsocket.js depends on uws.js, which contains the actual binaries, which have to be compatible with installed node ABI version (process.versions.modules) which is version 93 for node 16.

@md-seb
Copy link

md-seb commented Oct 29, 2021

npm i uwebsockets.js installs an older version
this worked: npm i uWebSockets.js@uNetworking/uWebSockets.js#v20.1.0

@kapouer
Copy link
Contributor

kapouer commented Oct 29, 2021

@darrachequesne you will probably appreciate the work of https://github.com/kartikk221/hyper-express

darrachequesne added a commit that referenced this issue Nov 2, 2021
```js
const { App } = require("uWebSockets.js");
const { uServer } = require("engine.io");

const app = new App();
const server = new uServer();

server.attach(app);

app.listen(3000);
```

Reference: https://github.com/uNetworking/uWebSockets.js

Related: #578
@darrachequesne
Copy link
Member

darrachequesne commented Nov 8, 2021

Added in [email protected]:

const { App } = require("uWebSockets.js");
const { uServer } = require("engine.io");

const app = new App();
const server = new uServer();

server.attach(app);

app.listen(3000, () => {});

I plan to merge the changes in Socket.IO, so we can benefit from the publish functionality.

Feedback is welcome!

darrachequesne added a commit to socketio/socket.io that referenced this issue Nov 12, 2021
Usage:

```js
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");

const app = new App();
const server = new Server();

server.attachApp(app);

app.listen(3000);
```

The Adapter prototype is updated so we can benefit from the publish
functionality of uWebSockets.js, so this will apply to all adapters
extending the default adapter.

Reference: https://github.com/uNetworking/uWebSockets.js

Related:

- #3601
- socketio/engine.io#578
dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
Usage:

```js
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");

const app = new App();
const server = new Server();

server.attachApp(app);

app.listen(3000);
```

The Adapter prototype is updated so we can benefit from the publish
functionality of uWebSockets.js, so this will apply to all adapters
extending the default adapter.

Reference: https://github.com/uNetworking/uWebSockets.js

Related:

- socketio#3601
- socketio/engine.io#578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants