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.

multiple connections react js

See original GitHub issue

Hi I have a problem !!!

When io connect to the server, Server log over and over: Like this: New client connected Client disconnected New client connected Client disconnected Client disconnected New client connected Client disconnected New client connected New client connected Client disconnected Client disconnected New client connected New client connected Client disconnected New client connected Client disconnected New client connected Client disconnected New client connected Client disconnected Client disconnected New client connected Client disconnected New client connected New client connected Client disconnected Client disconnected Client disconnected Client disconnected Client disconnected Client disconnected

Server Code: io.origins('*:*'); io.on('connection', (socket) => { console.log('New client connected'); socket.on('disconnect', () => { console.log('Client disconnected'); }); });

Client Code: import io from 'socket.io-client'; const socket = io.connect('http://192.168.1.34:3000');

What is wrong in my code??? Please help me

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
sajadgmcommented, Dec 2, 2020

install socket.io-client@2.3.1

5reactions
emericspirouxcommented, Jun 24, 2021

Yes @darrachequesne, I upgrading my server version to 4.1.2 after found a weird timeout on server socket.io’s debug logs and it’s work properly. 🎉 (I was at the 2.x 🤦)

Conclusion beware of your server and client socket.io versions 😅

If @skyredmilad confirm, we can close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React JS socket.io-client opens multiple connections
I have a simple React JS app connected to a socket io server. Whenever I open the app in the browser, the client...
Read more >
How to prevent multiple socket connections and events in React
How to prevent multiple socket connections and events in React · 1. Connect only once · 2. Bind and emit events only once...
Read more >
Socket io multiple connections in react application : r/node
I decided to learn socket io and do a little project with it, so I was following the docs creating an instance and...
Read more >
How to Avoid Multiple WebSocket Connections in a React ...
In this post, you'll learn how WebSocket connections work in a React Chat app and how to avoid concurrent connections with Stream's Chat ......
Read more >
My React app is opening multiple connections - Ably FAQs
There are a few obvious reasons that this might happen: The third issue is more subtle, and we shall illustrate it below. Imagine...
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