Long cycle times MQTT gateway



  • Hello all,
    I have an issue which I hope you can help me with.

    My gateway is a MQTT gateway running on an ESP8266. It works fine but I have noticed it sometimes is missing telegrams. I've added some debugging timing checks and I see that usually the maximum cycle time is around 40-50ms. That looks ok to me.

    The problem is that the cycle time sometimes goed up to 500 or even 2000ms. It is quite likely that if too many packages are send to the gateway during that time, these are not received and can't be handled.

    There are some locally attached sensors (a smart electricity meter and a doorbell) but even without these active in the software, the cycle times are sometimes high.

    Does any of you know how this can be improved?
    Thanks

    edit
    The long duration occurs in the publish() function


  • Mod

    @electrik Where is your broker located? Is it in a local network or some server on the internet?



  • @yveaux It is local. see also my edit in my original message, the long duration takes place in the publish() function


  • Mod

    @electrik if your broker responds slowly to the publish requests (for whatever reason) incoming messages may get lost. nRF24 for instance only has a 3 deep message buffer that will not be emptied by MySensors during the publish call. Once it's full, incoming messages will be dropped.



  • @yveaux Okay that makes sense. So when publishing, the pubsubclient library waits for an answer of the broker?
    Any idea how to find out what is happening and, even better, how to get rid of it?
    Do you have an idea of your cycle times?


  • Mod

    @electrik said in Long cycle times MQTT gateway:

    pubsubclient library waits for an answer of the broker?

    Not familiar with the actual implementation, but I wouldn't be surprised if it blocks until finished.

    Any idea how to find out what is happening and, even better, how to get rid of it?

    Either improve the performance of your broker, or buffer incoming messages.
    I'm using mosquitto as a broker and an atmega based gateway with message buffering enabled (unsupported for esp unfortunately)

    Do you have an idea of your cycle times?

    No, but I not aware of loosing messages.



  • @yveaux Thanks for your feedback.

    @yveaux said in Long cycle times MQTT gateway:

    Not familiar with the actual implementation, but I wouldn't be surprised if it blocks until finished.

    I've looked in the code but can't find any blocking there. It just writes and then returns. I think I'll ask the creator of the library about it.

    @yveaux said in Long cycle times MQTT gateway:

    No, but I not aware of loosing messages.

    It is not so noticeable, on my nodes I track if they have to resend messages and so can see the quality of the network. That's what I'm trying to improve.

    @yveaux said in Long cycle times MQTT gateway:

    Either improve the performance of your broker, or buffer incoming messages.
    I'm using mosquitto as a broker and an atmega based gateway with message buffering enabled (unsupported for esp unfortunately)

    I guess that is a better setup because of the buffering. I didn't know this before this started though...


  • Mod

    Can you try to switch to ethernet gw and see if you see any change?



  • @gohan well, switching the gateway sketch is easy to do but my node-red is based on mqtt sensors...


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 4
  • 15
  • 2
  • 3

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts