[SOLVED] huge delay with multiple gateways

  • Hi there!

    I have one MQTT gateway. All worked very well. Then added a 2nd gateway on a different channel and in my basement. There is no radio contact between the two.
    My configuration:

    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "hefti-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "hefti-in"

    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "hefti-3"

    both Gateways have different client IDs, but same publish/subscribe topics.

    It sometimes takes up to 30 seconds until a message is received by a sensor node (turning lights on), sometimes it is fast. turn it on/off several times, works very unpredictable.

    After pulling the plug on the 2nd gateway, all works again.

    Any ideas? Do I need to choose different publish/subscribe ID's for this? Or possibly QOS of the MQTT broker?


  • @parachutesj can you check to which Parent the nodes are connected?
    I don't think it is caused by mqtt, if you have different client IDs. What is the debug output of the gateway and nodes telling?

  • @electrik thanks.
    I would hope that they are just connected to the one they can talk to (via radio), right?
    Anyhow it is a bit complicated to debug them, they are in places where I cannot bring my PC.

    When I uploaded the 2nd one and had the first sensor ready, I noted in the log, that also messages from other sensors appeared but mentioned something that I cannot remember but something like "ignoring message".

    So this would be very strange if this is an issue as repeater nodes are all over the place and never had any issues.
    I am just thinking how many people do have a similar setup with gateways on different IDs and same MQTT topic.

    Will try to change the topic, then I can also get some hints from the log potentially.

  • @parachutesj said in huge delay with multiple gateways:

    I would hope that they are just connected to the one they can talk to (via radio), right?

    Well I guess it depends how far the channels are apart. If they are close I can imagine they will receive their both messages but maybe not as good as when they were on the same channel.

  • @parachutesj said in huge delay with multiple gateways:

    Will try to change the topic, then I can also get some hints from the log potentially.

    I don't think it is the topic, that is possible to use from more sources. Do you use unique IDs in both networks? And as mentioned the client IDs have to be different.

  • hi @electrik
    this is the log of the 2nd gateway. I am only receiving messages sent from the controller to the nodes, the temp sensors etc. on the other network are not visible on the 2nd gateway. They are both in the same room, now. So from radio perspective I think it is fine.

    node 121 is the only one which should be dealt with this 2nd gateway.

    If I understand it correct, for node 112 received comand to turn the lights on. The gateway says it is UNKNOWN and 112 is not reachable. So far so good.
    Question is, does it also arrive on 1st gateway? what is it doing with it...
    I think the "simple" fix will be changing the topic. Then it should be fine.
    However still thinking that there is something odd

    0;255;3;0;9;Sending message on topic: hefti-out/121/1/1/0/0
    0;255;3;0;9;Sending message on topic: hefti-out/121/0/1/0/1
    0;255;3;0;9;Sending message on topic: hefti-out/121/255/3/0/0
    0;255;3;0;9;Message arrived on topic: hefti-in/112/0/1/0/3
    0;255;3;0;9;Message arrived on topic: hefti-in/113/0/1/0/3
    0;255;3;0;9;!TSF:RTE:113 UNKNOWN
    0;255;3;0;9;Message arrived on topic: hefti-in/117/0/1/1/2
    0;255;3;0;9;!TSF:RTE:117 UNKNOWN
    0;255;3;0;9;Message arrived on topic: hefti-in/102/0/1/1/2
    0;255;3;0;9;!TSF:RTE:102 UNKNOWN
    0;255;3;0;9;Message arrived on topic: hefti-in/113/0/1/0/3
    0;255;3;0;9;!TSF:RTE:113 UNKNOWN
    0;255;3;0;9;Message arrived on topic: hefti-in/112/0/1/0/3

  • Mod

    @parachutesj I would not recommend to use the same topic root for both gateways. The root gets appended the node ID, therefore topics cannot be traced to/from the gateway the nodes are attached to. For incoming messages (coming from the nodes) this might seem convenient (if node IDs are unique over both networks) but for outgoing messages both gateways will transmit them.

  • thank you @Yveaux
    I changed it. Still same issue. I do not see any in the logs now. So I have different topics, different channels. both here.
    Both have different client ids, both different IP's
    I am lost.
    As soon as I connect the 2nd gateway to the network, turning on/off in sequence of one node works a few times, after 5/7 iterations it stops, then after a few seconds all messages appear in the gateway log, also on my mqtt-spy. So there is somewhere a hickup.
    after disconnection, I can turn on/off 40-50 times and no issues at all.

    looks like it is mosquitto as MQTT broker.

    Can we specify the mac address? maybe there is the problem with the "cheap" network adapters...

  • Mod

    @parachutesj the Mac addresses should be unique. They are passed as parameter to the begin() call of the ethernet stack iirr.
    Even after making them unique it might take a while for your network equipment to recover from duplicate Mac addresses (or power cycle them, including switches!).

  • @yveaux I think this was the issue.
    I just found that

    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAD

    will specify the MAC.
    After adding it, no more issues. Changed back to same topics on both gateways, seems this is no problem.

    Even the gateways received different IPs via DHCP, they had the same MAC. Haven't seen an issue in any logs.
    I am not sure about long term, but short it works now. Let me see if it is a permanent fix.
    Still pretty strange that I receive different IPs from my router for the same MAC.
    Sometimes these are the easy fixes...

    Thanks for your help!

Log in to reply

Suggested Topics

  • 3
  • 1
  • 24
  • 2
  • 2
  • 3