sgupta999 / mqtt-bridge-smartthings

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

Error on MQTT publish: "Client <unknown> disconnected due to protocol error." #25

Closed Epidurality closed 4 years ago

Epidurality commented 4 years ago

So the SmartApp/Device seem to play nicely together, and appear to be pushing the correct information when looking at SmartThings' Live Logging: 7:40:38 PM: debug Forwarding device event to bridge: {"path":"/push","body":{"name":"Desk Light","value":"86","type":"level"}} 7:40:38 PM: debug Received event 86 on attribute level for device Desk Light for BRIDGE 7:40:38 PM: debug Sending '{"path":"/push","body":{"name":"Desk Light","value":"86","type":"level"}}' to server

The mqtt-bridge-smartthings server (server? application? helper?) is running on the same Windows machine that my instance of Mosquitto is on.

2020-04-01 19:38:19 PM info: Loading configuration 2020-04-01 19:38:19 PM info: Loading previous state 2020-04-01 19:38:19 PM info: Last Request from ST - {} 2020-04-01 19:38:19 PM info: ===================================ACTUAL SUBSCRIPTIONS REQUESTED FROM SMARTAPP ============================================ 2020-04-01 19:38:19 PM info: Currently subscribed to 2020-04-01 19:38:19 PM info: ============================================================================================================================ 2020-04-01 19:38:19 PM info: Saving current state 2020-04-01 19:38:19 PM info: Connecting to MQTT at mqtt://192.168.1.45 2020-04-01 19:38:19 PM info: Configuring autosave 2020-04-01 19:38:19 PM info: Configuring API 2020-04-01 19:38:19 PM info: Listening at http://localhost:1883

And my Mosquitto instance is seeing connections and pings, seemingly correctly. However, whenever I change the device and it attempts to send something through MQTT, I get this in my Mosquitto logs: 2020-04-01T19:40:38: New connection from 192.168.1.33 on port 1883. 2020-04-01T19:40:38: Client <unknown> disconnected due to protocol error.

Hub is on .33, mosquitto/mqtt-bridge are on .45, mosquitto's only port is 1883 using mqtt protocol. I've googled around for what could be causing this error, but I couldn't get any posted solutions working.

Ideas?

sgupta999 commented 4 years ago

Configuring API 2020-04-01 19:38:19 PM info: Listening at http://localhost:1883

this port needs to be 8080 or whatever port you specified in mbs-bridge configuration in ST IDE

in config file

Port number to listen on

port: 8080

this is not the MQTT port

Epidurality commented 4 years ago

Thank you for the quick response!

Problem of reader error.. everything was so close to working that I didn't suspect to go back and read those Preferences names to realize you weren't asking for the MQTT Broker info but the Bridge info. I changed the port in the bridge's config.yml to 8080, and changed my MQTT Bridge Port in the MQTT Bridge ST Device to 8080 also. Looks to be working perfectly.

I'm guessing the config.yml doesn't need to specify the MQTT port since it assumes 1883 with the mqtt protocol. If we wanted to use a different port for our MQTT broker, is it possible to specify that in the config?

sgupta999 commented 4 years ago

yes right now 1883 is the default port that the node js library uses