I have many devices running the same program using node-RED’s MQTT node to publish messages to Losant’s MQTT Broker and to subscribe to the same broker for device commands.
The devices have correct authentication as they connect initially without issue but then they timeout (according to Losant) some of the devices are able to successfully reconnect and others aren’t.
For example device 4697:
Connects to Losant without issue:
But since December 3rd it has disconnected many times and continues to do so often citing the keepalive timeout:
Another device 4683 running the same program (with the only difference being authentication) connected successfully initially:
But unlike the other device it does not reconnect regularly and instead gets stuck in the connection process:
It seems that these disconnects are common across all connected gateways that are connected to Losant here is another example device 4723:
It is very strange as this issue started in the past few months as when we were testing this project initially within Losant we did not see these types of disconnects with our gateway devices.
Have there been any changes to Losant’s broker that need to be accounted for?
Any ideas on where or why this might be happening?
Best Regards,
Leo
Hi @Leo_Bach1,
I just wanted to update you that I am currently working on this. In the meantime, if you have any additional screenshots of your Node-RED configuration, they are incredibly helpful!
Thanks,
Julia
1 Like
Hi @Leo_Bach1,
Does your mqtt out still have the configuration from this post?
Thanks!
Julia
Yes all of our gateways are pulling in the Losant credentials from a file called env. We use a read file node to read this file and a function node to set those variables. I will post screen shots for this process soon.
Thanks for your help and attention.
1 Like
Hi @Leo_Bach1,
I am currently trying to isolate where this problem is occurring. I was wondering if you would be able to create a workflow with the same broker configuration, but with the fewest nodes possible. I am trying to decipher if the problem exists in the broker configuration, the connection to Losant, the node-RED workflow, or within Losant’s broker, and usually test by removing superfluous functionality. I would recommend setting up the workflow to connect at a minimum, then if this is successful, I would attempt to send data to and from Losant and see if the problem arises. I will message you momentarily if you would like to send your workflow for my own testing purposes!
Thanks!
Julia
Hi @Leo_Bach1,
I did get your DM, thank you! I have not yet worked with it as I was hoping to hear your results from the debugging suggestions before digging deeper, and see if you were able to get a stable connection with a basic workflow? Or what behavior you may have observed?
Thanks!
Julia
Hi @Leo_Bach1,
I have a suspicion that the mqtt://
prefix may be what is causing the headaches here. I tested this myself, once with broker.losant.com
as the Server, and once with mqtt://broker.losant.com
. When I tried the server without the mqtt://
, I connected almost immediately and had no issues. However, when I tried with the prefix, it did not error or connect, and I only discovered from my logs that there was a problem:
java.lang.IllegalArgumentException: tcp://mqtt://broker.losant.com:1883
I would recommend removing mqtt://
, and seeing if you are able to connect then.
Thanks!
Julia
For future Losanters experiencing similar issues:
I finally found two issues regarding our connectivity:
- Routing Priority of the gateway
- DNS settings
Apparently our gateway was connecting to our VPN and seeing the VPC running the VPN service as the default gateway but due to a less than optimal configuration of the routing priorities sometimes it would connect to the VPN and sometimes it would connect through cellular. When it would connect through cellular it would set a second default gateway (which should never happen) to be the Cellular Provider’s connection point.
The DNS was not set to static so if we connected to the Losant broker initially (via the domain broker.losant.com) it was fine until the IP Address that the domain originally pointed to changed. So the issue with the DNS setting was that the IP Address of the domain wasn’t updated.
I am now setting all of my gateways to static DNS and pointing to google’s DNS servers.