简体   繁体   English

Node.JS + Express + Socket.IO-WebSocket连接无效信息

[英]Node.JS + Express + Socket.IO - websocket connection invalid info

I recently found a script on GitHub which allows you to run a real-time Node.JS chat application, using Express and Socket.IO dependencies. 我最近在GitHub上找到了一个脚本,该脚本允许您使用Express和Socket.IO依赖项运行实时Node.JS聊天应用程序。 I have uploaded it to my newly acquired DigitalOcean VPS, running Ubuntu 12.04. 我已将其上载到运行Ubuntu 12.04的新购买的DigitalOcean VPS。

It works , but is very slow to start with, ie it takes ~10 seconds to load, and when I run node app.js command via SSH, I get this debug info in my terminal - http://pastebin.com/r48xHN3m - the app starts up with socket.IO, BUT, on line 8 you can see that there's a clear socket.IO warning, stating that the websocket connection is invalid. 的工作原理 ,但速度很慢与启动,即它需要约10秒加载,当我运行node app.js通过SSH命令,我让我的这个终端调试信息- http://pastebin.com/r48xHN3m -该应用程序以socket.IO启动,但在第8行中,您可以看到明显的socket.IO警告,指出websocket连接无效。 And then it goes on to do some XHR polling after the timeout, and in the end of the debug info (line 38), you can see that a new user has joined the group, so it does work. 然后它会在超时后做一些XHR轮询和调试信息(38行)结束时,你可以看到一个新的用户加入该组,所以它工作。

I've read a lot on the web about this, but I still can't solve the error. 我已经在网上阅读了很多有关此内容的信息,但仍然无法解决该错误。 I tried using SSL (port 443), updating and upgrading all the dependencies, but those minor tweaks just don't do it... 我尝试使用SSL(端口443),更新和升级了所有依赖项,但是那些细微的调整只是不做...

PS My experimental site with the node app installed, but with socket.IO errors (running on port 3000) - chat.notepad.li PS我的实验站点已安装节点应用程序,但出现socket.IO错误(在端口3000上运行) -chat.notepad.li

Update: 更新:

After scouring the web, I found out that all I needed to do was to first: upgrade my nginx installation, and secondly: update my nginx configuration block that is shown on this website . 在网上搜索后,我发现我要做的就是首先: 升级我的nginx安装,其次: 更新网站上显示的nginx配置块 I then restarted the nginx service and, voila - the chat app loads up in less than a second. 然后,我重新启动了nginx服务,瞧-聊天应用程序的加载时间不到一秒钟。 The website also stated that " SSL is apparently the way to go " - 该网站还指出,“ 显然SSL是必经之路 ”-

Incidentally, it would have worked if I had used SSL on port 443. According to WebSocketsTest's aggregate data , port 443 is supported about 89% of the time, compared to 78% for port 80. 顺便说一句,如果我在端口443上使用SSL,它会起作用。根据WebSocketsTest的汇总数据 ,端口443的支持时间约为89%,而端口80的支持率为78%。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM