how to connect to a WebSocket

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS)

expo app won’t connect to a WebSocket, it keeps throwing " WebSocket error "

import io from  "socket.io-client" ;       
                                                                       
const SocketEndpoint = 'http://myserver.com'; 


useEffect(() => {
    tryLocalSignin();
   
        const socket = io(SocketEndpoint , {
          transports: ['websocket'],
          path: '/orders'
        });
        socket.connect(); 
        socket.on('connect', () => {
          setConnect(true);
          socket.emit('joinRoom', { merchant_reference })
          console.log("Conntected")
        });
      socket.on('connect_error', (err) => {
        console.log(err);
      });
      
     // socket.emit('joinRoom', { merchant_reference })
  }, [])

The error message I am getting is shown below
websocket error

  • node_modules/engine.io-client/lib/transport.js:63:20 in

  • node_modules/engine.io-client/lib/transports/websocket.js:149:2 in WS.prototype.addEventListeners

  • node_modules/event-target-shim/dist/event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent

  • node_modules/react-native/Libraries/WebSocket/WebSocket.js:262:10 in _eventEmitter.addListener$argument_1

  • node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:190:12 in emit

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0

  • [native code]:null in callFunctionReturnFlushedQueue