socket.io-client not working on Android API 28 (React Native)

Created on 27 Feb 2020  ·  4Comments  ·  Source: socketio/socket.io-client

I want to use Socket.IO-client with React Native. My environment:

  • React Native 0.61.5
  • React 16.9.0
  • Socket.IO-client ^2.3.0

My code works on iOS, but not on Android. I'm testing on Android version 9.0 (Pie) - API 28. I do not get any errors, it just doesn't work. I'm trying to log every connection server-side (NodeJS). When I open the app in the iOS-emulator, I see a log (eg. "connection established"). When I open the same app using Android, I don't see a log.

Front-end code (simplified!): React Native

```import io from 'socket.io-client
socket = io('https://127.0.0.1:8001', {
secure: true,
transports: ['websocket']
})
socket.on('message', () => console.log('message received'))
socket.close()

**Back-end code** (simplified!): NodeJS

```const io = require('socket.io')(https)
io.on('connection', socket => {
    console.log('connection established')
    socket.on('disconnect', () => console.log('disconnected'))
})

Most helpful comment

Same issue, without transports: ['websocket'] it works.

Edit: I switched to [email protected] and seems to be working.

All 4 comments

Same issue here 😥

Same issue, without transports: ['websocket'] it works.

Edit: I switched to [email protected] and seems to be working.

Same Issue I am facing....

Was this page helpful?
0 / 5 - 0 ratings