sgupta999 / mqtt-bridge-smartthings

MQTT Bridge To SmartThings [MBS]
MIT License
27 stars 15 forks source link

MQTT Bridge crash : TypeError: Cannot convert undefined or null to object #17

Open jmbinette opened 4 years ago

jmbinette commented 4 years ago

Hi to all,

MQTT bridge service is continuoulsy restarting and I have the error :

2020-01-20 11:06:42 AM info: Listening at http://localhost:8082 2020-01-20 11:06:42 AM debug: From MQTT: smartthings/maison-rpi4/winesensor_cellier_1/battery/set_state = 97 /usr/local/lib/node_modules/mqtt-bridge-smartthings/mbs-server.js:477 Object.keys(subscribe[topic]).forEach(function(name) { ^ TypeError: Cannot convert undefined or null to object at Function.keys () at MqttClient.parseMQTTMessage (/usr/local/lib/node_modules/mqtt-bridge-smartthings/mbs-server.js:477:10) at MqttClient.emit (events.js:189:13) at MqttClient._handlePublish (/usr/local/lib/node_modules/mqtt-bridge-smartthings/node_modules/mqtt/lib/clie at MqttClient._handlePacket (/usr/local/lib/node_modules/mqtt-bridge-smartthings/node_modules/mqtt/lib/clien at work (/usr/local/lib/node_modules/mqtt-bridge-smartthings/node_modules/mqtt/lib/client.js:283:12) at process._tickCallback (internal/process/next_tick.js:61:11) mqtt-bridge-smartthings.service: Main process exited, code=exited, status=1/FAILURE mqtt-bridge-smartthings.service: Failed with result 'exit-code'. [+] 0.2.197 20-01-2020 11:06:48 am [CMD-ERRO] fatal mqtt error - messages may not be delivered as intended (network is down. e mqtt-bridge-smartthings.service: Service RestartSec=10s expired, scheduling restart. mqtt-bridge-smartthings.service: Scheduled restart job, restart counter is at 183. Stopped SmartThings - MQTT Bridge. Started SmartThings - MQTT Bridge.

jmbinette commented 4 years ago

I deleted state.json and restarted the bridge.

Any code modifications possible to prevent crashing on wrong data type ?

sgupta999 commented 4 years ago

I think you might be on an older version of the server. Could you please update to latest version and let me know if you are still seeing the error?

jmbinette commented 4 years ago

Hi,

I just updated my version, we will see

For my other issue on the SmartThings forum, I will open another issue right away

Thanks