信息 - 未处理的 socket.io url [英] info - unhandled socket.io url

查看:25
本文介绍了信息 - 未处理的 socket.io url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做 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?

谢谢

推荐答案

几天前遇到了确切的问题,看起来 socket.io 的 API 有一些变化.

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

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

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

本质上有两个变化

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

var socket = io.listen(server);
socket.sockets.on('connection', function(client)  

  • 在客户端 - 不需要 URL 和端口,因为它是自动检测的.

  • On Client side - URL and port not required as it is autodetected.

    var socket = io.connect();
    

  • 注意:您也可以在客户端io.connect("http://<ip>:<port>"),但是不再需要,因为它是自动检测的

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

    以下是确切的更改 - https://github.com/parj/node-websocket-demo/commit/5ba52db9d1a5b7e8a3af5839adcd12768741dc97

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

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

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

    这篇关于信息 - 未处理的 socket.io url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆