14

I've been using socket.io to create a websocket enabled server in node.js, and its great. Now i'd like however, to create a server-side client in node.js which can connect to a websocket server elsewhere. Are there any libraries out there for this?

Thanks

noli
  • 15,927
  • 8
  • 46
  • 62
  • 1
    This question duplicates: http://stackoverflow.com/questions/3842565/is-there-a-browserless-websocket-client-for-node-js-that-does-not-need-to-use-a/8055463#8055463 See my extensive answer there. – colin moock Nov 08 '11 at 18:48

3 Answers3

4

https://github.com/pgriess/node-websocket-client <-- does this one work for you?

Found on this list here: https://github.com/joyent/node/wiki/modules

jcolebrand
  • 15,889
  • 12
  • 75
  • 121
  • This doesn't quite work if we're talking specifically about socket.io -- there is a minimal protocol involved including a heartbeat. Check out the bootstrap code in my example that strips off the header and responds to heartbeats. – Josh May 20 '11 at 23:16
  • This does work thanks.. its not ideal (as mentioned above), but it does the basics for now – noli May 21 '11 at 00:06
  • @Noli I never saw in your comment if you had tried it, so ... my apologies if you had. Perhaps you can contribute some code with any improvements you make? – jcolebrand May 21 '11 at 01:26
2

Not any that are great.

I talked to Guillermo about this on mailing list a couple days ago, see http://groups.google.com/group/socket_io/browse_thread/thread/74e9ff6d7e931f6e

I wrote this as a bootstrap to help in my testing: https://github.com/jmoyers/mettle/blob/master/test/test-socket.coffee#L18-49

Guillermo is working on one here for 0.7: https://github.com/LearnBoost/Socket.IO-node-client

Josh
  • 12,602
  • 2
  • 41
  • 47
1

I've just been working on a project with similar needs: a Node server that acts as a Socket.io server and connects to another service via proper websockets. I used the ws module for the websocket client in Node.

Do be aware that, as noted above by Josh, Socket.io is a protocol on top of web sockets.

Oliver Moran
  • 5,137
  • 4
  • 31
  • 45