Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket hung up error on react native android #82

Closed
cogmeta opened this issue Jun 17, 2017 · 5 comments
Closed

Socket hung up error on react native android #82

cogmeta opened this issue Jun 17, 2017 · 5 comments

Comments

@cogmeta
Copy link

cogmeta commented Jun 17, 2017

I know this has been posted multiple times and it is always some simple configuration mistake or version mismatch but no matter what we try, we cant seem to get rid of this error "SocketProtocolError", message: "Socket hung up". The server and client works fine with web browsers Chrome and Firefox but not with react native. Can someone help? Thanks in advance.

socketcluster-server@5.14.0
socketcluster-client@5.5.1

import socketCluster from 'socketcluster-client';
const socketOptions = {
hostname: 'xxx.xxxx.xxx',
secure : true,
port: 443
};

this.chatsocket = socketCluster.connect(socketOptions);
this.chatsocket.on('connect', this.onSocketConnect.bind(this));
this.chatsocket.on('proxyReply', this.onSocketMessage.bind(this));
this.chatsocket.on('error', this.onSocketError.bind(this));

SocketProtocolError {name: "SocketProtocolError", message: "Socket hung up", code: 1006, stack: "SocketProtocolError: Socket hung up↵ at SCSocke…m=android&dev=true&hot=true&minify=false:8669:42)"}

@cogmeta
Copy link
Author

cogmeta commented Jun 17, 2017

socketerror

@cogmeta cogmeta closed this as completed Jun 17, 2017
@jondubois
Copy link
Member

@cogmeta Did you manage to find the solution?

@cogmeta
Copy link
Author

cogmeta commented Jun 17, 2017

@jondubois Yes, Thank you. There were lots of things to fix (protocol option in socketOption, uws engine on server side, nginx settings). I will write a checklist that might benefit others as well while troubleshooting.

@Louies89
Copy link

Louies89 commented Feb 6, 2018

Hi @cogmeta
I am trying to connect to socketcluster server using react native. I am using below scWorker code to connect:
class Worker extends SCWorker {
run() {
var httpServer = this.httpServer;
var scServer = this.scServer;
scServer.on('connection', function (socket) {
console.log('client :'+ socket.id + ' connected.');
})
}
}

And from client side
var Newsocket = socketCluster.connect({
hostname: 'localhost',
port: 80})

But it throws following error
image
Can you help me out please?

And is it, I have to connect to the server using http first then i have to fire
var Newsocket = socketCluster.connect({
hostname: 'localhost',
port: 80})
from client side?

@sacOO7
Copy link
Member

sacOO7 commented Feb 6, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants