简体   繁体   English

Node + socket.io-奇怪的响应时间

[英]Node + socket.io - weird response time

I have Node.js application which is dedicated to listen and emit websockets only. 我有专门用于侦听和发出websocket的Node.js应用程序。 My stack is up-to-date. 我的堆栈是最新的。 I'm using clean Socket.io client server setup from this page: 我正在从此页面使用干净的Socket.io客户端服务器设置:

http://socket.io/docs/ http://socket.io/docs/

I discovered that once in a while it takes about 15-25 seconds to get a response from node js server. 我发现有时需要大约15-25秒才能从node js服务器获得响应。 Usually it takes up to 5 ms but one every 20, 30 or 40 calls take up to 25 seconds. 通常,它最多需要5毫秒,但每20、30或40个呼叫中的一个会花费25秒。 I found that out when I send some message to server, receive a response and calculate time spend on that transaction (like most benchmarking apps do). 我发现,当我向服务器发送一些消息,收到响应并计算在该事务上花费的时间时(就像大多数基准测试应用程序一样)。 I tried different configuration, transport method etc, and it's the same. 我尝试了不同的配置,传输方法等,并且是相同的。

I run it on Apache/2.2.14. 我在Apache / 2.2.14上运行它。 I prepared quickly similar test for Sock.js and response time never goes above 5 ms. 我为Sock.js快速准备了类似的测试,并且响应时间从未超过5毫秒。

Did anyone have the same issue? 有人遇到过同样的问题吗? What could be the reason? 可能是什么原因? I know I can just use Sock.js but the thing is that big app is already done on Socket.io and it would be hard to rewrite it to use different socket package. 我知道我可以只使用Sock.js,但事实是,大型应用程序已经在Socket.io上完成,因此很难重写它以使用其他套接字包。

Cheers. 干杯。

After couple of hours of debugging I found a problem which is... Kaspersky antivirus on my local machine. 经过几个小时的调试,我发现一个问题是...我的本地计算机上的卡巴斯基防病毒软件。 I've setup socket my server on port 8080. Kaspersky does not block websockets but is scanning this port. 我已经在8080端口上设置了服务器套接字。卡巴斯基不会阻止websocket,但是正在扫描该端口。 And 1 in 20 sockets takes 20 seconds to get a response. 每20个插槽中有1个需要20秒才能获得响应。 Solution: changing the port to something that is not scanned by antiviruses (not sure but 3000 or 843 should do the trick). 解决方案:将端口更改为不被防病毒程序扫描的端口(不确定,但可以使用3000或843来解决问题)。

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

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