SocketCluster / SocketCluster/socketcluster
worker crash in "Socket hung up" exception when closing react-native clients
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6.2k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
Our team implemented a client side socketCluster in react-native (iOS & Android).
It worked correctly. but when a client application (iOS or Android) closed, the "Socket hung up" exception occurred and the current worker not worked either.
our server-side codes are:
//our codes in worker.js
var scServer = this.scServer;
scServer.on('connection', function (socket) {
console.log('socket #' + socket.id + ' connected in (' + process.pid + ')');
socket.on('message', function (data) {
console.log('message (' + process.pid + "): ", data);
});
socket.on('close', function (data) {
console.log('socket #' + socket.id + ' closed in (' + process.pid + "): ", data);
});
socket.on('error', function (data) {
console.log('error.name in (' + process.pid + "): ", data.name);
console.log('error.message in (' + process.pid + "): ", data.message);
console.log('error in (' + process.pid + "): ", data);
});
});
the exception in server side is:
error.name in (23190): SocketProtocolError
error.message in (23190): Socket hung up
error in (23190): { SocketProtocolError: Socket hung up
at SCServerSocket._onSCClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/scserversocket.js:249:17)
at WebSocket.<anonymous> (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/scserversocket.js:80:10)
at WebSocket.emit (events.js:182:13)
at WebSocket.emitClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/node_modules/ws/lib/websocket.js:180:10)
at Socket.socketOnClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/node_modules/ws/lib/websocket.js:802:15)
at Socket.emit (events.js:182:13)
at TCP._handle.close (net.js:611:12)
name: 'SocketProtocolError',
message: 'Socket hung up',
code: 1006 }
1550930660777 - Origin: Worker (PID 23190)
[Warning] SocketProtocolError: Socket hung up
at SCServerSocket._onSCClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/scserversocket.js:249:17)
at WebSocket.<anonymous> (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/scserversocket.js:80:10)
at WebSocket.emit (events.js:182:13)
at WebSocket.emitClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/node_modules/ws/lib/websocket.js:180:10)
at Socket.socketOnClose (/Users/ali/IdeaProjects/SocketClusterBackend/node_modules/socketcluster-server/node_modules/ws/lib/websocket.js:802:15)
at Socket.emit (events.js:182:13)
at TCP._handle.close (net.js:611:12)
It seems there is an uncaught exception that crash worker (started with 1550930660777).
I read the below issue:
[https://github.com/SocketCluster/socketcluster/issues/41]
// server.js
socketCluster.on('fail', function(error)
{
console.log(error);
});
// worker.js
worker.on('error', function(error)
{
console.log(error);
});
but there is not the worker object to set on-error in worker.js file and listening to 'fail' event of SocketCluster object in server.js file not catch this exception.
so if our problem is from the uncaught exception, please help me to handle this exception or any solution to our problem.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the React Native client close and trace the SocketProtocolError from SCServerSocket._onSCClose in scserversocket.js. Review the worker.js and server.js event handlers, including the documented fail and error listeners. Done means closing an iOS or Android client no longer crashes or disables the worker, with the disconnect handled appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, react-native
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100