Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
socket create multiple connection even when only one user connected

I'm new to Socket i try to receive image from server using socket-client-io . i can able to get image but on server side it shows multiple user created but i'm only seeing it in one tab but it shows like 10 users connected(like that)

Code:

const socket = io('ws://localhost:5000')
    socket.on('connnection', () => {
      console.log('connected to server');
    })
 socket.on('disconnect', () => {
      console.log('Socket disconnecting');

    })

    useEffect(() => {
      const handler = (message) => {
        setImage(message.image);
        console.log(message);
      };
      socket.on("send_image", handler);
      return () => socket.off("send_image", handler); // assuming `.off` deregisters a callback
    }, []);

it works fine and i can get images but it create multiple connection for single tab kindly guide me how to avoid this

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!