question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Socket events getting too much time to fire

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

24reactions
luffscommented, Feb 24, 2018

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' });

2reactions
clawdaddycommented, May 17, 2018

I was having a similar issue. I fixed it by changing the connection from a proxy to the server directly: before: client side

const socket = openSocket(`/`)

after

const socket = openSocket(`http://localhost:3030`)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.IO events getting too much time to fire - Stack Overflow
I am using socket.io for my chat app. (HTML + JS & node js). It's working fine and great when one client connects...
Read more >
Socket event listener fires multiple times in React component
My first attempt was this, whenever there's any re-render, socket.on('USER_JOINED') would registers the same callback function passed into it so ...
Read more >
Migrating from 3.x to 4.0 - Socket.IO
The "disconnect" event would take a long time to fire in the browser, probably due to a timer being delayed. Hence the change....
Read more >
Socket io event fired Multiple Times Fix - YouTube
Aoa GuysMake sure to like and subscribe. Socket io firing event multiple times Reactsocket io event fired multiple timessocket io same event ......
Read more >
Socket.IO, React and Node.js: Going Real-Time
We can listen for a connection event, fire up a function when a new ... emit a message (basically an event) over a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found