socketio / socket.io-client

Realtime application framework (client)
https://socket.io
10.62k stars 3.04k forks source link

socket.io can not connect in react-native 0.59 #1294

Closed Luomusha closed 5 years ago

Luomusha commented 5 years ago

Current behaviour

Emit an "Connect error" event after try to connect socket.

Steps to reproduce (if the current behaviour is a bug)

Expected behaviour

What is expected?

Setup

Other information (e.g. stacktraces, related issues, suggestions how to fix)

ReactFabric-prod.js:6973 connectxerror: Error: xhr poll error
    at XHR.Transport.onError (browser.js:265)
    at Request.<anonymous> (socket.js:406)
    at Request.Emitter.emit (socket.js:353)
    at Request.onError (socket.js:636)
    at socket.js:583
    at ReactNativeRenderer-dev.js:9719
    at _callTimer (ReactNativeRenderer-dev.js:9628)
    at Object.callTimers (ReactNativeRenderer-dev.js:9863)
    at MessageQueue.__callFunction (ReactNativeART.js:312)
    at ReactNativeART.js:95
ReactFabric-prod.js:6992 manager open Error: Connection error
    at Socket.<anonymous> (index.js:60)
    at Socket.Emitter.emit (socket.js:353)
    at Socket.onError (socket.js:180)
    at XHR.<anonymous> (debug.js:95)
    at XHR.Emitter.emit (socket.js:353)
    at XHR.Transport.onError (browser.js:267)
    at Request.<anonymous> (socket.js:406)
    at Request.Emitter.emit (socket.js:353)
    at Request.onError (socket.js:636)
    at socket.js:583

I created a new react-native project in 0.59 with react-native-cli, then added soket.io-client.

const manager = new Manager('http://127.0.0.1:3000', {
      reconnection: false,
      autoConnect: false,
      reconnectionDelay: 5000,
      reconnectionAttempts: 3,
      // transports: ['websocket'],
      // transports: ['polling'],
      query: {
        userId: 1,
        token: '1231312132321'
      }
    })

just report error.

Luomusha commented 5 years ago

Android simulator 8.1.0 debug mode

Luomusha commented 5 years ago

it's my bad. In android 127.0.0.1 means the simulator itself.