I was using this lib for a year and everything is going fine.
I was start using RN 0.45, and 0.48 , and then 0.53.0. Everything is perfect.
Until I upgrade to react native 0.53.3, and this issue appear.
this is the error I got
{"type":"TransportError","description":{"line":"76","collumn":"7944","sourceURL":"index.android.bundle"}}
sometimes i got "timeout"
I didn't change any code, I didn't change any dependency.
What I did just:
I thought it might the React native issue, so I roll back to the previews version I was used 0.53.0. But this problem still exist. I roll back again to 0.48, the issue still there. and so on.
I use socket.io-client 2.0.3 (I have try 2.0.4 but not help)
I have no Idea what is going on.
Hope someone will help. Thank you
+1
I resolved this by adding 'transports': ['websocket'],
option
this.socket = openSocket(socketUrl,{
'reconnection': true,
'reconnectionDelay': 500,
'reconnectionAttempts': Infinity,
'transports': ['websocket'],
});
But that option is not required, am I right?
So I keep this issue open because it will break when I omitting that option.
i did have this issue after i add express to the server and added some routes
and when i added
'transports': ['websocket'],
it works fine but it disconnect after a while and
PS: it disconnect while i'm working with the app not in backround or something else.
Could you please provide a way to reproduce? (I tried with jest with no luck: https://github.com/darrachequesne/jest/commits/test/socket.io)
Setting transports to websocket also solved my problem, but of course turns off http polling which is unfortunate. Steps to reproduce:
I have the same problem on iOS, the temporary solution of adding the option 'transports': ['websocket']
also worked for me.
Configuration:
I am trying to connect socket.io on my react native android. however, it is not connecting. I tried some tutorials and iOS is working fine but Android is not. I have tried the 'transports':['websocket']
but still not working :( .. Any suggestions or ideas or sample codes?
My backend is Nodejs and it also used socket.io. Thanks!
I am trying to connect socket.io on my react native android. however, it is not connecting. I tried some tutorials and iOS is working fine but Android is not. I have tried the
'transports':['websocket']
but still not working :( .. Any suggestions or ideas or sample codes?My backend is Nodejs and it also used socket.io. Thanks!
Did you find any solution to this i have the same problem on react-native on Android.
same issue
hello guys I have a problem on socket
it show timeout when I check on
socket.on('connect_error', (err) => {
console.log('error123',err)
here is my code
for react native side
import io from 'socket.io-client';
var socket = io.connect('http://localhost:8888',{transports: ['websocket'],upgrade:false});
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
socket.on('connect_error', (err) => {
console.log('error123',err)
});
server side:
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(8888);
// WARNING: app.listen(80) will NOT work here!
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
index.html
I already stock need help
Even I have the issue connecting the socket-io on android. The RN is able to get connected as the client however the same for the react web app but not react mobile app. Please suggest the solution.
Try downgrading socket.io-client to 1.7.2, it works for me.
I am having issues in connecting the websocket (socket.io-client, trnasport:['websocket']) on iOS with the webserver.
Interestingly, it works when I turn on "Debug JS Remotely" on the device.
This might be a problem with the react-native version on iOS. Just curious if someone is facing the same issue.
Most helpful comment
I am having issues in connecting the websocket (socket.io-client, trnasport:['websocket']) on iOS with the webserver.
Interestingly, it works when I turn on "Debug JS Remotely" on the device.
This might be a problem with the react-native version on iOS. Just curious if someone is facing the same issue.