Skip to content

Commit 5fd45ae

Browse files
author
abanks
committed
Trap exceptions in onSocket message callback.
1 parent 7d76bf0 commit 5fd45ae

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/mqttws31.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Messaging = (function (global) {
8282
// Private variables below, these are only visible inside the function closure
8383
// which is used to define the module.
8484

85-
var version = "0.0.0.0";
85+
var version = "@VERSION@";
8686
var buildLevel = "@BUILDLEVEL@";
8787

8888
/**
@@ -1088,7 +1088,8 @@ Messaging = (function (global) {
10881088
}
10891089
this._trace("Client._on_socket_message", wireMessage);
10901090

1091-
switch(wireMessage.type) {
1091+
try {
1092+
switch(wireMessage.type) {
10921093
case MESSAGE_TYPE.CONNACK:
10931094
this._connectTimeout.cancel();
10941095

@@ -1231,7 +1232,11 @@ Messaging = (function (global) {
12311232

12321233
default:
12331234
this._disconnected(ERROR.INVALID_MQTT_MESSAGE_TYPE.code , format(ERROR.INVALID_MQTT_MESSAGE_TYPE, [wireMessage.type]));
1234-
};
1235+
};
1236+
} catch (error) {
1237+
this._disconnected(ERROR.INTERNAL_ERROR.code , format(ERROR.INTERNAL_ERROR, [error.message]));
1238+
return;
1239+
}
12351240
};
12361241

12371242
/** @ignore */

0 commit comments

Comments
 (0)