Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Long cycle times MQTT gateway

Long cycle times MQTT gateway

Scheduled Pinned Locked Moved Troubleshooting
9 Posts 3 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • electrikE Offline
    electrikE Offline
    electrik
    wrote on last edited by electrik
    #1

    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

    YveauxY 1 Reply Last reply
    0
    • electrikE electrik

      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

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #2

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

      http://yveaux.blogspot.nl

      electrikE 1 Reply Last reply
      0
      • YveauxY Yveaux

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

        electrikE Offline
        electrikE Offline
        electrik
        wrote on last edited by
        #3

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

        YveauxY 1 Reply Last reply
        0
        • electrikE electrik

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

          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by
          #4

          @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.

          http://yveaux.blogspot.nl

          electrikE 1 Reply Last reply
          0
          • YveauxY Yveaux

            @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.

            electrikE Offline
            electrikE Offline
            electrik
            wrote on last edited by
            #5

            @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?

            YveauxY 1 Reply Last reply
            0
            • electrikE electrik

              @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?

              YveauxY Offline
              YveauxY Offline
              Yveaux
              Mod
              wrote on last edited by Yveaux
              #6

              @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.

              http://yveaux.blogspot.nl

              electrikE 1 Reply Last reply
              0
              • YveauxY Yveaux

                @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.

                electrikE Offline
                electrikE Offline
                electrik
                wrote on last edited by
                #7

                @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...

                1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #8

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

                  electrikE 1 Reply Last reply
                  0
                  • gohanG gohan

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

                    electrikE Offline
                    electrikE Offline
                    electrik
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    29

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.1k

                    Posts


                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • MySensors
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular