Web Server Sockets Implementation for NodeJS

I cannot help but feel that I need to answer this, but I am damned if I find it. Part of the problem may be that there are too many client-side discussions for me to see a tree for trees.

In any case, apologies aside, that’s what I want to do. I need a platform-independent server implementation of WebSockets. I would like him to work at NodeJS.

Now, 99% of what I found in this thread is talking about socket.io. But as far as I can tell, these are not WebSockets, this is a special "additional" protocol in itself. I need something that works "by the (not yet) standard." There is a good reason for this, and it is not negotiable, believe me, and just keep the bandwidth :)

So, I tried WebSocket, but it requires (or seems to require both python and, worse, Visual Studio) to work on Windows. I need something platform independent and don't need such special things.

I also tried node -websocket-server, but I can't get this to work at all. The example on the main page is not suitable for me. It seems that he accepts the connection, but the client does not see it, neither side receives anything, and the client immediately sees the connection closed. In fact, all I have ever received is a “callback” callback, and then it seems to die. Running in debug mode did not tell me anything useful, except for some internal error about some object or another that does not have the flush () method. I suspect this is a non-existent project?

So I have no ideas. Is it possible to convince socket.io to work exclusively with (non) spec for WebSockets? Is there a way to make node-websocket-server behave in a way that I could not find. Is there a way around the Visual Studio dependency in websocket, or is there some other NodeJS based tool that meets all my requirements?

Oh, one more thing, I would like the tool to coexist peacefully with “connectivity” as I use this for my regular document.

TIA, Toby

+5
source share
2 answers

I had the same problem that you encountered when I was trying to use Socket.IO on another platform without a direct client port (and without any motivation for him).

I ended up moving my code to use ws , which is the standard implementation of websocket for node without adding sugar from socket.io.

It works fine in my case on several different platforms, but you will need to process most of the connection / reconnection code, etc.

Website: Link

GitHub: link

NPM: npm install ws

+4
source

Socket.io uses WS under covers, so you may run into the same installation problem on Windows. You may find that it complains that you need to install Visual Studio 2010 for the ws component to work.

However, you can customize the version of Visual Studio used by node-gyp , which launches the C ++ compiler through an environment variable.

Examples:

  • set GYP_MSVS_VERSION=2012 for Visual Studio 2012
  • set GYP_MSVS_VERSION=2013e ("e" means "express release")

See the full list in the section - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

This is very painful for Windows users from NodeJS, as it assumes that you have a copy of Visual Studio installed for many non-developer end users. So I lobby Joyent to encourage them to include web sockets as part of the CORE node, and also send the GNU gcc compiler as part of the NodeJS installation so that we can permanently fix this problem and not force Windows node users to configure their environment or load something- or else.

Feel free to add your vote:

NOTE. The Joyent team has indicated that socket.io will revert to using a slower implementation when ws fails. In other words, your code will still work - just not so fast. This is not clear to the end users installing any application that depends on socket.io or ws, because it displays a red error text during the installation process, and leading users assume that the installation failed when it actually works, although and slowly.

0
source

All Articles