B4J Question Many Problems with jMQTT & Broker [SOLVED]

jmon

Well-Known Member
Licensed User
Longtime User
[EDIT] Solved Post#9

Hi,

I've been working with MQTT for about 2 months now. I'm using jMQTT on 5 raspberry pi. 1 windows machine is both a MQTT client and the jMQTTBroker. Every client is connected directly by cable to the router.

Everything works quite well when I have only 2-3 raspberry pi ON, but when I turn ON all 5 of them, I run into many problems.

Problems I encounter:
- clients disconnect and reconnect themselves sometimes
- broker drops connection with some of the clients
- some clients try to connect indefinitely until I restart the broker
- clients disconnect themselves permanently until reboot RPI

Many error messages on the broker side (with QOS = 1):
Serious error processing the message org.eclipse.moquette.proto.messages.PubAckMessage@e26484 for session [clientID: 5]org.eclipse.moquette.server.netty.NettyChannel@8e99d7
some other error messages (red colored) I forgot to copy.

My broker has a fixed IP address. For the raspberry pi, I tested both having a fixed, and DHCP assigned IP address. I tested with QOS 1, 2, but get same behavior.

I was wondering how reliable is MQTT? Should I switch to a jServer solution or sockets instead? Have any of you run into problems with MQTT?

Thank you
Jmon.
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Test it with mosquitto broker
Thank you but that didn't help, I have the same problem.
Pls check the client names
Thank you, I did, but each of my client has a unique id.

The biggest problem I'm running into now, is that some clients take very long time to transmit their messages. Sometimes it takes up to 10 seconds to send the message to broker. It's very inconsistent. Most of the time they will reply fast, but 1 out of 10 times, it will be slow to reply. Could it be caused by b4xSerializator?

Does b4xSerializator need to write files on the SD card? because that could be the problem, my RPIs may be busy writing something on a separate thread when they reply (they are writing an image taken with Raspistill).

I tried disabling the firewalls (windows) but no luck.

I'm starting to think that the RPI could just be slow, and can't handle my program. But they are just taking a picture with Raspistill, with jShell Async. For information, they are all Raspberry Pi 3. I'm running Jessie Lite (no GUI), latest version.

Thank you all for your help. I continue searching :)

[edit] all RPIs have a different hostname too.
 
Last edited:
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Try to set the QOS to 0. It can improve the overall performance.
Thank you, I already set the QOS to 0, it speeds up the transactions, but still get that lag in most of the times.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Turns out the problem was not related to MQTT! Apologies to jMQTT ;)

The problem was electrical: not enough power for my RPIs. Aparently the RPI will shutdown the network connections momentarily (or permanently) if there is not enough power. This was confusing, because the RPI would not shutdown or reboot, but just loose the network connection for a moment, hence the lag that I experienced. In my case, the power consumption came after taking many pictures with Raspistill, the network would go down.

I found the solution after reading this page:
http://elinux.org/R-Pi_Troubleshooting#Ethernet_connection_is_lost_when_a_USB_device_is_plugged_in
Ethernet connection is lost when a USB device is plugged in
This is often caused by inadequate power. Use a good power supply and a good power cable. Some cheap cables that work with a cell phone, cannot fully power the R-Pi. Some USB devices require a lot of power (>100 mA), so they must be used with a powered USB hub. Some cheap USB hubs suck power from the Raspberry Pi even if a USB power supply is connected. (More often than not, however, the reverse is true with cheap hubs—the Pi draws just enough power backwards from the powered hub to unsuccessfully attempt booting.)

There is an ongoing issue with the Ethernet connection being lost when low-speed devices, such as mice or keyboards are connected via a powered USB hub. The simplest way to solve this is to connect your mouse and keyboard directly into the 2 USB ports on the R-Pi (assuming they draw less than 100 mA apiece).

Changing the power source has fixed the problem! MQTT works perfectly and has no problem!

Thank you everyone for your help!
 
Upvote 0
Top