Socket events getting too much time to fire
See original GitHub issueI am using socket.io for my chat app. (HTML + JS & node js). It’s working fine and great when one client connects to it.
But when another window is opened to start the chat, the chat becomes very slow. When three or four users connect to the chat at the same time, it’s getting even slower such that, it looks like, it’s almost freezed.
FYI, throughout the application, I have used socket.emit()
(with & without callbacks). My requirement is, receive a message from the client, respond to the client. It’s no group chat or anything. The user will chat with a bot (server). Said that, the message sent by the user (to the server) will not be sent to any other users. So, I fond that socket.emit()
is the right way to deal with in this case.
Am I getting it wrong? Should I use some other way for emitting?
Note:- The application works perfectly when running inside the enide studio with the inbuilt node js server. But, when deployed, the events are extremely slow.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:22 (4 by maintainers)
Top GitHub Comments
Also see https://github.com/socketio/socket.io/issues/3100 . A workaround is to change the wsEngine to ws in the options:
const io = require('socket.io')(httpServer, { wsEngine: 'ws' });
I was having a similar issue. I fixed it by changing the connection from a proxy to the server directly: before: client side
after