简体   繁体   中英

React-Native socket.io no connection

I wanted to use socket.io in my RN project. Everything was ok, until I disabled chrome debugger. Now socket.io just doesn't work, nothing happens.

This is not the same problem: Is it possible to combine React Native with socket.io

What's your React Native version?

In your url add ws:// like :

var soc = socket('ws://192.168.1.101',{
  jsonp: false
})

It works fine on device with RN v0.21.0.

After I upgrade RN to 0.24.0, it doesn't work again.

I have also got this problem. I fixed this from this link

You have to initialize socket like this

this.socket = io('http://192.168.0.101', {jsonp: false, transports: ['websocket']});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM