Home > Back-end >  Socket implementation is showing problem in react js
Socket implementation is showing problem in react js

Time:07-20

On implementing the socket.io-client in my project it is showing an error and the connection status is false.

This is the code of socket.

 socket = io('url', {
    transports: ['websocket']
 })
 console.log(socket)

and I am using the socket version

 "socket.io-client": "^4.5.1",

But the console is showing

 It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)

CodePudding user response:

Changed Version from

"socket.io-client": "^4.5.1",

To

"socket.io-client": "^1.7.4",

And Changed

import {io} from "socket.io-client

To

import io from "socket.io-client
  • Related