aboutsummaryrefslogtreecommitdiff
path: root/websockets
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-06-20 21:15:05 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-06-20 21:15:05 +0200
commit970bbda9c884e36c7148a7d921d67c8253c13cdb (patch)
tree251f7e780b0a7fe96bb603ac9fa67051e6c4f8ae /websockets
parent2675fac7fe07783d3266b59f6e1c0e0a337a84db (diff)
websockets: More robust in case of connection closures
Diffstat (limited to 'websockets')
-rwxr-xr-xwebsockets/server.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/websockets/server.js b/websockets/server.js
index 86307e6..b650ce1 100755
--- a/websockets/server.js
+++ b/websockets/server.js
@@ -63,6 +63,9 @@ wsServer=wsServer.ws("/*",{
linebuf=linebuf.slice(idx+1);
}
});
+ stateobj.netconn.on("error",()=>{
+ if(!stateobj.sock_closed)sock.close();
+ });
},
message: (sock,data,isBinary)=>{
const stateobj=sock["tomsgdata"];
@@ -77,7 +80,8 @@ wsServer=wsServer.ws("/*",{
close: sock=>{
const stateobj=sock["tomsgdata"];
stateobj.sock_closed=true;
- stateobj.netconn.end();
+ try {stateobj.netconn.end();}
+ catch (e) {}
}
});