v5.0.17 'socket hangup' error for React Native iOS Only, works for Browser and Andriod
bikashsharmabks opened this issue · 12 comments
@bikashsharmabks What options do you pass to socketCluster.connect(...)
? Did does it work with v5.0.14
?
I tested it v5.0.17
on RN iOS yesterday and it worked for me - So maybe it's related to settings.
@bikashsharmabks Also, what version of socketcluster
and socketcluster-server
are you using on the server side?
Version Details:
socketcluster": 5.0.18
Here is the code which I have
var options = {
hostname: 'dev.sandbox.com',
path: '/mySocketEventCluster',
port: 80,
}
this.socket = socketCluster.connect(options);
this.socket.on('connect', function (err) {
console.log('CONNECTED');
//Alert.alert('hi','connected');
});
this.socket.on('error', function (err) {
console.log(err);
//Alert.alert('err', err.message);
});
Note this works in browser, RN Android but not in RN iOS
@bikashsharmabks Maybe try to setup a very simple app (from scratch) with only basic SC logic to connect and emit/publish events and let me know if it works. We need to rule out the possibility that this is caused by some other code which is interfering with SC like middleware...
Yesterday I did a very simple test with socketcluster-client v5.0.17 and it was connecting, publishing and receiving messages with socketcluster v5.0.18 on the server side - It was running on iOS simulator on Mac.
@jondubois It worked I took a sample code from socketcluster getting started and it worked for RN iOS!!!
But still wondering what is issue with my configuration as it works with Android and browser and not with iOS
@jondubois I got the issue I was setting wsEngine to 'ws' which is not workging for iOS and when I change it to 'uws' it worked!!!
so is there any issue with 'ws'?
Interesting, on RN iOS on the client side, it will use the native WebSocket object provided by RN which in theory should be compatible with both ws and uws on the server, but maybe this is not the case, I'll have to check.
@jondubois thanks a lot for your help.
Please go ahead and close this issue or otherwise if you want to track the wsengine issue with this one
@bikashsharmabks it would be really help full if you tell me how you configured the socket cluster client in react native android.
This does not work in react-native iOS for protocol:HTTPS port:443 server. Trying secure ws connections hasn't worked for me, but it works using localhost. Please advise.
@NomadGraphix There is no protocol
option, there is a secure
(boolean) option though. See the list of supported options here: http://socketcluster.io/#!/docs/api-socketcluster-client
@jondubois Well, that is quite interesting. 👍
@yogi9999999, @bikashsharmabks The documentation looks to be lacking on github: https://github.com/SocketCluster/socketcluster-client
This is what I was using, but it is out of date.
var options = {
protocol: 'https',
hostname: 'example.com',
port: 443
};
// Initiate the connection to the server
var socket = socketCluster.connect(options);