New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapid Messages will Crash the Client? #55

Open
kerti opened this Issue Feb 13, 2015 · 14 comments

Comments

Projects
None yet
7 participants
@kerti

kerti commented Feb 13, 2015

Hi! First of all, kudos on your great work.

I've been using your library to subscribe to an MQTT topic, and then relay the message to another Arduino "field unit" via RF links using RadioHead. Here's the sketch if you'd like to take look at it:

https://github.com/kerti/catleya-arduino/blob/master/baseStation/baseStation.ino

I use openHAB to publish messages to MQTT based on what switch I press on my handset. So, all goes well when I test one switch and just leave it alone. But when I mash on the controls and make openHAB spit out a bunch of messages rapidly, eventually the Arduino just goes silent, and I presume it's crashed.

I don't know what happened, maybe you could check it out and see if I crashed the client?

@knolleary

This comment has been minimized.

Show comment
Hide comment
@knolleary

knolleary Feb 13, 2015

Owner

Hi, I don't see anything obviously wrong with your code.

I've not generally had an issues like this, but then I'm not sure I've ever tried swamping the device with messages.

What have you done to try to debug it?

Owner

knolleary commented Feb 13, 2015

Hi, I don't see anything obviously wrong with your code.

I've not generally had an issues like this, but then I'm not sure I've ever tried swamping the device with messages.

What have you done to try to debug it?

@kerti

This comment has been minimized.

Show comment
Hide comment
@kerti

kerti Feb 13, 2015

All I've done is add some code to check my available memory, because my first suspicion was that I somehow used up all memory. This isn't the problem. I haven't tried anything else.

If you have any other ideas I'd be happy to try it out and report back.

kerti commented Feb 13, 2015

All I've done is add some code to check my available memory, because my first suspicion was that I somehow used up all memory. This isn't the problem. I haven't tried anything else.

If you have any other ideas I'd be happy to try it out and report back.

@kerti

This comment has been minimized.

Show comment
Hide comment
@kerti

kerti Feb 25, 2015

Reporting back, I think we simply shouldn't send that many messages at a time. I modified my server to limit itself to a maximum of 1 message per 10 seconds, and it seemed to work fine.

kerti commented Feb 25, 2015

Reporting back, I think we simply shouldn't send that many messages at a time. I modified my server to limit itself to a maximum of 1 message per 10 seconds, and it seemed to work fine.

@swell-d

This comment has been minimized.

Show comment
Hide comment
@swell-d

swell-d Mar 1, 2015

I had the same problem. After some time my arduino stops to respond.
Problem was with my DHCP server. I set static IP on my arduino and my router set the same IP to another device on my network =)

swell-d commented Mar 1, 2015

I had the same problem. After some time my arduino stops to respond.
Problem was with my DHCP server. I set static IP on my arduino and my router set the same IP to another device on my network =)

@swell-d

This comment has been minimized.

Show comment
Hide comment
@swell-d

swell-d Mar 1, 2015

kerti, how did you limit the server?

swell-d commented Mar 1, 2015

kerti, how did you limit the server?

@kerti

This comment has been minimized.

Show comment
Hide comment
@kerti

kerti Mar 1, 2015

swell-d, I use openHAB to send my MQTT messages. What server do you use?

kerti commented Mar 1, 2015

swell-d, I use openHAB to send my MQTT messages. What server do you use?

@swell-d

This comment has been minimized.

Show comment
Hide comment
@swell-d

swell-d Mar 1, 2015

The same. I use MQTT event bus for outgoing messages.

swell-d commented Mar 1, 2015

The same. I use MQTT event bus for outgoing messages.

@kerti

This comment has been minimized.

Show comment
Hide comment
@kerti

kerti Mar 1, 2015

@swell-d, I simply created an item that I don't show on my UI, and use rules to compare it to the actual items in the UI. An example would make explaining easier:

I have an 8-channel relay attached to an Arduino which I complained about at the top of this thread. I currently have these items:

gRelays_Garage_RELAY01_Device01
gRelays_Garage_RELAY01_Device02
gRelays_Garage_RELAY01_Device03
gRelays_Garage_RELAY01_Device04
gRelays_Garage_RELAY01_Device05
gRelays_Garage_RELAY01_Device06
gRelays_Garage_RELAY01_Device07
gRelays_Garage_RELAY01_Device08

I add another item that I don't show on my UI:

gRelays_Garage_Status

At this point, I don't use any bindings on any items.

I create a rule that looks something like this:

rule "[Update RELAY.01]"
when
    Time cron "10 * * * * ?" // check every 10 seconds
then
    var int statusMask = 0

    if (gRelays_Garage_RELAY01_Device01.state == ON)
        statusMask = statusMask + 1

    if (gRelays_Garage_RELAY01_Device02.state == ON)
        statusMask = statusMask + 2

    if (gRelays_Garage_RELAY01_Device03.state == ON)
        statusMask = statusMask + 4

    if (gRelays_Garage_RELAY01_Device04.state == ON)
        statusMask = statusMask + 8

    if (gRelays_Garage_RELAY01_Device05.state == ON)
        statusMask = statusMask + 16

    if (gRelays_Garage_RELAY01_Device06.state == ON)
        statusMask = statusMask + 32

    if (gRelays_Garage_RELAY01_Device07.state == ON)
        statusMask = statusMask + 64

    if (gRelays_Garage_RELAY01_Device08.state == ON)
        statusMask = statusMask + 128

    if (statusMask.toString() != gRelays_Garage_Status.state.toString())
        sendCommand(gRelays_Garage_Status, statusMask)
end

I can then use the gRelays_Garage_Status to trigger sending the MQTT message, either by binding or by rules. I hope this helps.

kerti commented Mar 1, 2015

@swell-d, I simply created an item that I don't show on my UI, and use rules to compare it to the actual items in the UI. An example would make explaining easier:

I have an 8-channel relay attached to an Arduino which I complained about at the top of this thread. I currently have these items:

gRelays_Garage_RELAY01_Device01
gRelays_Garage_RELAY01_Device02
gRelays_Garage_RELAY01_Device03
gRelays_Garage_RELAY01_Device04
gRelays_Garage_RELAY01_Device05
gRelays_Garage_RELAY01_Device06
gRelays_Garage_RELAY01_Device07
gRelays_Garage_RELAY01_Device08

I add another item that I don't show on my UI:

gRelays_Garage_Status

At this point, I don't use any bindings on any items.

I create a rule that looks something like this:

rule "[Update RELAY.01]"
when
    Time cron "10 * * * * ?" // check every 10 seconds
then
    var int statusMask = 0

    if (gRelays_Garage_RELAY01_Device01.state == ON)
        statusMask = statusMask + 1

    if (gRelays_Garage_RELAY01_Device02.state == ON)
        statusMask = statusMask + 2

    if (gRelays_Garage_RELAY01_Device03.state == ON)
        statusMask = statusMask + 4

    if (gRelays_Garage_RELAY01_Device04.state == ON)
        statusMask = statusMask + 8

    if (gRelays_Garage_RELAY01_Device05.state == ON)
        statusMask = statusMask + 16

    if (gRelays_Garage_RELAY01_Device06.state == ON)
        statusMask = statusMask + 32

    if (gRelays_Garage_RELAY01_Device07.state == ON)
        statusMask = statusMask + 64

    if (gRelays_Garage_RELAY01_Device08.state == ON)
        statusMask = statusMask + 128

    if (statusMask.toString() != gRelays_Garage_Status.state.toString())
        sendCommand(gRelays_Garage_Status, statusMask)
end

I can then use the gRelays_Garage_Status to trigger sending the MQTT message, either by binding or by rules. I hope this helps.

@swell-d

This comment has been minimized.

Show comment
Hide comment
@swell-d

swell-d Mar 1, 2015

Yes! Thank you

swell-d commented Mar 1, 2015

Yes! Thank you

@sjcliffe

This comment has been minimized.

Show comment
Hide comment
@sjcliffe

sjcliffe Dec 23, 2015

I ran into this problem too but found a workaround using the mosquitto broker.

By sending the messages with a QOS of 1 and setting the mosquitto config variable max_inflight_messages to 1 results in the messages being delivered to the subscriber one at a time - i.e. message 2 will only be sent after the client ACKs message 1.

sjcliffe commented Dec 23, 2015

I ran into this problem too but found a workaround using the mosquitto broker.

By sending the messages with a QOS of 1 and setting the mosquitto config variable max_inflight_messages to 1 results in the messages being delivered to the subscriber one at a time - i.e. message 2 will only be sent after the client ACKs message 1.

@JamesM85

This comment has been minimized.

Show comment
Hide comment
@JamesM85

JamesM85 Jan 11, 2016

I have also been experiencing this issue and have got around it by using QOS of 1.

In my case just sending two messages consecutively would sometimes cause it to crash. Are there any plans to investigate the issue further?
Thanks
James

JamesM85 commented Jan 11, 2016

I have also been experiencing this issue and have got around it by using QOS of 1.

In my case just sending two messages consecutively would sometimes cause it to crash. Are there any plans to investigate the issue further?
Thanks
James

@bensuffolk

This comment has been minimized.

Show comment
Hide comment
@bensuffolk

bensuffolk May 11, 2016

I have just experienced this issue. I have built a module with 8 relays and a command looks like "/VBCM/xxxxxxxx/01/set" = "on" where xxxxxxxx is the serial number and 01 is the channel number.

If I send all 8 channels,one after the other 1 time out of 3 it tends to lock up. Sometimes it resets the sketch, most of time it does not.

I can reproduce this pretty consistently so am going to see if I can debug it.

bensuffolk commented May 11, 2016

I have just experienced this issue. I have built a module with 8 relays and a command looks like "/VBCM/xxxxxxxx/01/set" = "on" where xxxxxxxx is the serial number and 01 is the channel number.

If I send all 8 channels,one after the other 1 time out of 3 it tends to lock up. Sometimes it resets the sketch, most of time it does not.

I can reproduce this pretty consistently so am going to see if I can debug it.

@bensuffolk

This comment has been minimized.

Show comment
Hide comment
@bensuffolk

bensuffolk May 11, 2016

Ok,

After some fairly extensive testing I find that I have a hardware issue and nothing is wrong with the library. It's all to do with my relay circuit, if I don't have the relays connected there is no problem.

So that's good news for the library, and I need to make some tweaks to my design.

Ben

bensuffolk commented May 11, 2016

Ok,

After some fairly extensive testing I find that I have a hardware issue and nothing is wrong with the library. It's all to do with my relay circuit, if I don't have the relays connected there is no problem.

So that's good news for the library, and I need to make some tweaks to my design.

Ben

@cristovao-trevisan

This comment has been minimized.

Show comment
Hide comment
@cristovao-trevisan

cristovao-trevisan Aug 29, 2016

I had the same problem, but upgrading the library solved it.
Check if you are using the last version (2.6 at the time I wrote this).

cristovao-trevisan commented Aug 29, 2016

I had the same problem, but upgrading the library solved it.
Check if you are using the last version (2.6 at the time I wrote this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment