1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Do not crash on malformed json message on websocket.

This commit is contained in:
Mark Hindess 2014-07-24 14:46:04 +01:00
parent 6bc4b235bb
commit 8506fd0c4b

View File

@ -50,7 +50,13 @@ function start() {
} }
}); });
ws.on('message', function(data,flags) { ws.on('message', function(data,flags) {
var msg = JSON.parse(data); var msg = null;
try {
msg = JSON.parse(data);
} catch(err) {
util.log("[red:comms] received malformed message : "+err.toString());
return;
}
if (msg.subscribe) { if (msg.subscribe) {
handleRemoteSubscription(ws,msg.subscribe); handleRemoteSubscription(ws,msg.subscribe);
} }