This is the first time I'm working with mqtt, be kind :)
Sometimes, the MQTT connection connects, receives a few messages, goes offline and reconnects again and again. The cycle takes about 5 seconds. This is the logs that I get in the console:
MQTT Connect
MQTT Message from Channel
MQTT Offline
MQTT Reconnecting
MQTT Connect
MQTT Offline
MQTT Reconnecting
It never stops. I also get a lot of 101 http requests every second:
Request URL: wss://myserver:8083/
Request Method: GET
Status Code: 101 Switching Protocols
---
Response headers:
Connection: Upgrade
Sec-WebSocket-Accept: 8MLdWBXF8YJ919JhE98mxM4R8IA=
Sec-WebSocket-Protocol: mqtt
Upgrade: WebSocket
I'm using the MQTT.js
mqtt client with these options:
{
keepalive: 10
username: "OOsj6Q0kX3xTVCfLi6QA"
password: "NKRsJYfD3ulms9s43Qho"
clientId: "2906890"
reconnectPeriod: 1000
connectTimeout: 30000
port: 8083
protocol: "wss"
hostname: "myserver"
}
The MQTT.js docs are not very beginner friendly and I'm struggling to understand the problem. Any idea what could be the problem?
Why I get a lot of 101 http requests? What does it mean?
Why it goes offline again and again? Under what conditions the connection goes offline? Bad internet connection?