Note: for support questions, please use one of these channels: stackoverflow or slack
For bug reports and feature requests for the Swift client, please open an issue there.
For bug reports and feature requests for the Java client, please open an issue there.
What is actually happening?
After upgrade from 2.3.0 to 3.0.1 getting error in react-native
-Create new react-native project.
-Install socket.io-client.
-Use it in your code.
Note: the best way (and by that we mean the only way) to get a quick answer is to provide a failing test case by forking the following fiddle.
What is expected?
To work properly.
OS: Android
browser:
I have the same issue with my react native project, it's working well on iOS but I get this error with android.
versions:
"react-native": "0.63.3",
"socket.io-client": "^3.0.1",
The error comes during the connection:
io.connect('http://192.168.1.81:3750');
Still trying to understand.
me too facing same issue after upgrading my libs, all the app works fine, but socket throw this same error:
versions:
"react-native": "0.63.3",
"socket.io-client": "^3.0.1",
I'm new to react-native and I'm also experiencing this issue, is there a known work around?
socket.[email protected]
I downgraded to version 2.3.1, that fixes the issue.
yarn add socket.[email protected]
Hi everyone. I could indeed reproduce.
Is there a way we can find the line that is triggering this error?
@darrachequesne I read your commit and added
{withCredentials: false}
in socket configs and it works, so the code would be like this:
io(SOCKET_URL, {
withCredentials: false,
})
@Mohamed-Rajab-2112 you are right, explicitly setting withCredentials
should work :+1:
It should be fixed by [email protected]
(which is included in [email protected]
). Could you please confirm?
I updated the React Native example with Socket.IO v3 here: https://github.com/socketio/socket.io/tree/master/examples/react-native
I'm having the same issue but only for my RN project in Typescript. My other RN project written in JS doesn't have this issue. And { withCredentials: false }
is not an option in SocketClient.Socket
.
@Rc85
I'm having the same issue but only for my RN project in Typescript. My other RN project written in JS doesn't have this issue. And
{ withCredentials: false }
is not an option inSocketClient.Socket
.
Yes you are right, withCredentials
is not part of config interface however, I think you should solve this as typescript issue, but try to ignore the ts error just for test sake if this solution would work with you or not.
for typescript, you may try to extend the socket config and add withCredentials
to it, just to make typescript not complaining.
Adding the withCredentials
stopped the error, but I cannot connect to my server. On my server, it shows the connection coming in and console log is spammed with reconnection
io.on('connection', (socket) => {
console.log('Connecting');
}
but on client side, connected is false.
{"_callbacks": {"$connecting": [[Function onConnecting]]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_autoConnect": true, "_callbacks": {"$close": [Array], "$open": [Array], "$packet": [Array]}, "_randomizationFactor": 0.5, "_readyState": "opening", "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 1000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "backoff": {"attempts": 0, "factor": 2, "jitter": 0.5, "max": 5000, "ms": 1000}, "connecting": [[Circular]], "decoder": {}, "encoder": {}, "engine": {"_callbacks": [Object], "hostname": "10.0.0.100", "id": null, "opts": [Object], "pingInterval": null, "pingTimeout": null, "pingTimeoutTimer": null, "port": "80", "prevBufferLen": 0, "readyState": "opening", "secure": false, "transport": [XHR], "transports": [Array], "upgrades": null, "writeBuffer": [Array]}, "nsps": {"/": [Circular]}, "opts": {"hostname": "10.0.0.100", "path": "/socket.io", "port": "80", "secure": false, "withCredentials": false}, "skipReconnect": false, "subs": [[Object], [Object], [Object]], "uri": "http://10.0.0.100"}, "nsp": "/", "receiveBuffer": [], "sendBuffer": [], "subs": [{"destroy": [Function destroy]}, {"destroy": [Function destroy]}, {"destroy": [Function destroy]}]}
I tried downgrading to 2.3.1 but cannot start my RN project's metro server because of module ../util
in node_modules\engine.io-client\lib\transports\polling-xhr.js
cannot be resolved. Didn't have this issue with my RN project written in JS, if that matters.
I opened an issue in engine.io-client's repo.
@darrachequesne so to test it, should I npm uninstall socket.io-client
and run npm install socket.io-client
to get the latest update ?
Adding the
withCredentials
stopped the error, but I cannot connect to my server. On my server, it shows the connection coming in and console log is spammed with reconnectionio.on('connection', (socket) => { console.log('Connecting'); }
but on client side, connected is false.
{"_callbacks": {"$connecting": [[Function onConnecting]]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_autoConnect": true, "_callbacks": {"$close": [Array], "$open": [Array], "$packet": [Array]}, "_randomizationFactor": 0.5, "_readyState": "opening", "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 1000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "backoff": {"attempts": 0, "factor": 2, "jitter": 0.5, "max": 5000, "ms": 1000}, "connecting": [[Circular]], "decoder": {}, "encoder": {}, "engine": {"_callbacks": [Object], "hostname": "10.0.0.100", "id": null, "opts": [Object], "pingInterval": null, "pingTimeout": null, "pingTimeoutTimer": null, "port": "80", "prevBufferLen": 0, "readyState": "opening", "secure": false, "transport": [XHR], "transports": [Array], "upgrades": null, "writeBuffer": [Array]}, "nsps": {"/": [Circular]}, "opts": {"hostname": "10.0.0.100", "path": "/socket.io", "port": "80", "secure": false, "withCredentials": false}, "skipReconnect": false, "subs": [[Object], [Object], [Object]], "uri": "http://10.0.0.100"}, "nsp": "/", "receiveBuffer": [], "sendBuffer": [], "subs": [{"destroy": [Function destroy]}, {"destroy": [Function destroy]}, {"destroy": [Function destroy]}]}
I tried downgrading to 2.3.1 but cannot start my RN project's metro server because of module
../util
innode_modules\engine.io-client\lib\transports\polling-xhr.js
cannot be resolved. Didn't have this issue with my RN project written in JS, if that matters.I opened an issue in engine.io-client's repo.
Okay, i will give it a check later tonight :)
Temporary fix at the moment, for me at least is downgrading socket.io-client to 2.3.1. However, engine.io-client raised the mentioned error because its' looking for the ../util
module somewhere, which doesn't exist in engine.io-client version 3.4.4. I had to do npm install engine.io-client@latest
to resolve the error.
Now I can connect to my server. Gonna stick with 2.3.1 for now.
@Rc85 Guys just updated the package few hours ago, try the new version i think it solved the issue, good luck!
This should be fixed by https://github.com/socketio/engine.io-client/commit/ccb99e3718e8ee2c50960430d2bd6c12a3dcb0dc.
Please run npm install socket.io-client@3
to force the update of the dependencies (or npm update --depth 9999 engine.io-client
).
If you use Expo, you may have to clear its cache with expo start --clear