Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I connect to a SockJS server from Node.js?

I have a SockJS server running in Node.js. Now I would like to connect to this server, not from a browser, but from another Node.js server.

sockjs-client is browser only, and sockjs-node does not provide a client part.

Of course I could use a module such as ws (or any other module which is RFC 6455-compliant), but then I lose all the nice functionality of the SockJS server such as fallbacks et al.

How can I connect to SockJS from Node.js?

like image 299
Golo Roden Avatar asked Nov 18 '25 10:11

Golo Roden


1 Answers

You can use sockjs-client from node too. Check the following packages:

  1. sockjs-client only XHR Streaming transport
  2. sockjs-client-ws only WebSocket transport
like image 157
user568109 Avatar answered Nov 20 '25 01:11

user568109



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!