I
I
ince2019-10-06 17:12:21
Node.js
ince, 2019-10-06 17:12:21

Which module for websockets is preferable - express-ws or ws.js?

Which module for websockets is preferable - express-ws or ws.js ?
Or should ws.js only be used when express is not used ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-10-06
@ince

express-ws suggests that we use multiple websocket connections and use express's router to route messages coming through those multiple connections.
ws assumes that you create one server, messages come through it and there you already resolve them.
In fact, the difference is not so great, just the declaration of the server socket is slightly different in its appearance.
Both packages can be used without express.
express-ws uses ws internally. Also
, pay attention to the number of issues for these packages.
Total: if you have several different websocket connections - you can take express-ws, if there is one connection - there is no point in this wrapper. But in general, little will change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question