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

452
Views
websocket error: can't connect socket.io to react-native project

I am using socket.io Version: ^4.5.1 in a chat application, but I am facing this error:

websocket error

my code:

import {io} from 'socket.io-client';
import {server} from 'store/config';

export const connectSocket = (token: string, eventId: string) => {
  const socket = io(server.stageSocketUrl, {
    transports: ['websocket', 'polling'],
  });

  socket.on('connect', () => {
    console.log('connected');
    socket.emit('join', {
      authorization: `Bearer ${token}`,
      eventId,
    });
  });

  socket.on('connect_error', err => {
    console.log(err, 'connect error');
  });
  return {socket};
};

when I use "socket.io-client": "^2.2.0" it connects to server successfully, so any clue how can I use version ^4.5.1 and make websocket connect to the server?

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!