info - 未处理的 socket.io url

发布于 2024-11-29 20:01:25 字数 233 浏览 3 评论 0原文

我正在开发一个 socket.io + node 项目。 就像在这个页面中一样, http://davidwalsh.name/websocket 我在 socket.io v7 中收到“信息 - 未处理的 socket.io url”错误。但我在 v6.17 中没有收到此错误?您对这个错误有什么想法吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩人痒 2024-12-06 20:01:25

几天前就遇到了确切的问题,看起来 socket.io 对 API 进行了一些更改。

我有一个 socket.io 发送和接收消息的工作演示 - 上传到 https://github。 com/parj/node-websocket-demo 作为参考

本质上有两个更改

  1. 在服务器端 - 将 socket.on 更改为 socket.sockets.on

    var socket = io.listen(server);
    socket.sockets.on('连接', 函数(客户端)  
    
  2. 在客户端 - URL 和端口不需要,因为它是自动检测到的。

    var socket = io.connect();
    

注意:您还可以在客户端使用 io.connect("http://:"),但是,不再需要,因为它是自动检测的,

以下是确切的信息变化 - https://github.com/parj/node-websocket-demo/commit/5ba52db9d1a5b7e8a3af5839adcd12768741dc97

这已经使用 Express 2.5.2 和 Socket.io 0.8.7 进行了测试

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文