info - unhandled socket.io url

天大地大妈咪最大 提交于 2019-12-30 10:35:30

问题


I working on a socket.io + node project. Just like in this page, http://davidwalsh.name/websocket I am getting "info - unhandled socket.io url" error in socket.io v7. But I dont get this error with v6.17? Do you have any idea with this error?

Thanks


回答1:


Had the exact issue couple of days back and looks like socket.io had some changes in the API.

I have a working demo of socket.io sending and receiving a message - uploaded to https://github.com/parj/node-websocket-demo as a reference

Essentially two changes

  1. On Server side - changed socket.on to socket.sockets.on

    var socket = io.listen(server);
    socket.sockets.on('connection', function(client)  
    
  2. On Client side - URL and port not required as it is autodetected.

    var socket = io.connect();
    

NOTE: you can also io.connect("http://<ip>:<port>") on the client side, however, not required anymore as it is autodetected

Here are the exact changes - https://github.com/parj/node-websocket-demo/commit/5ba52db9d1a5b7e8a3af5839adcd12768741dc97

This has been tested using Express 2.5.2 and Socket.io 0.8.7



来源:https://stackoverflow.com/questions/7069202/info-unhandled-socket-io-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!