Web Sockets server side implementation for NodeJS

前端 未结 2 1480
栀梦
栀梦 2021-01-13 10:41

Part of this problem might be that there\'s too much discussion on the client side for me to see wood for the trees.

Anyway, here\'s what I want to do. I need a plat

相关标签:
2条回答
  • 2021-01-13 11:21

    Socket.io uses WS under the covers so you may hit the same installation issue 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 configure the version of Visual Studio used by node-gyp that runs the C++ compiler via an environment variable.

    Examples:

    • set GYP_MSVS_VERSION=2012 for Visual Studio 2012
    • set GYP_MSVS_VERSION=2013e (the 'e' stands for 'express edition')

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

    This is a painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed which many non-dev end users will never have. So I'm lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem and not have to force Windows node users to tweak their environment or download anything else.

    Feel free to add your vote at:

    • https://github.com/joyent/node/issues/8005#issuecomment-50545326

    NOTE: The Joyent team have indicated that socket.io will fall back to using a slower implementation when compiling ws fails. In other words your code will still run - just not as fast. This is not clear for end users performing an install of any app that depends on socket.io or ws as it display red error text during the install process leading users to assume that the install failed, when in fact it will work albeit slowly.

    0 讨论(0)
  • 2021-01-13 11:25

    I had the exact same problem that you're facing at the moment when I tried to use Socket.IO on a different platform without a direct port of the client (and without the motivation to port it myself).

    I ended up moving my code to use ws which is a standards based websocket implementation for node without the added sugar from socket.io.

    It works extremely well in my case over several different platforms but you would need to rework most of the connection/reconnection code etc.

    Website : link

    GitHub : link

    NPM : npm install ws

    0 讨论(0)
提交回复
热议问题