Pubsub-mqtt limited publication

Hello, I’m testing the example of bradzilla84 pubsub-mqtt. The problem comes when the messages arrive in a row from mqtt. If I send them very close together, the microcontroller freezes and does not respond.
Programmed with arduino, using the pubsubclient library, I have not had problems of this type. Does anyone know why it does this?

"Hola, estoy probando el ejemplo de bradzilla84 pubsub-mqtt. El problema surge cuando los mensajes llegan en fila desde mqtt. Si los envío muy juntos, el microcontrolador se congela y no responde. Pero programado con arduino, utilizando la libreria pubsubclient, no he tenido problemas de este tipo ¿alguien sabe por que sucede esto?

I have been looking at the code of mqtt-device and mqtt-subscribe, it turns out that the reception is limited to 10 messages, I have been able to change the parameters so that many more can arrive, but when reaching the fixed messages, the program stops showing the messages messages received, is there a way to make this work without having to change the parameters?

he estado mirando el codigo de mqtt-device y mqtt-subscribe, resulta que esta limitada la recepcion a 10 mensajes, he podido cambiar los parametros para que puedan llegar muchos mas, pero al llegar a los mensajes fijados, el programa deja de mostrar los mensajes recibidos, ¿hay alguna forma de hacer que esto fuencione sin tener que cambiar los parametros?

mqtt-device’s messageReceived function executes a conditional that limits the Buffloc counter to 10, and when it is greater resets it to 0. If I change it to a number X, it allows me to receive more messages, up to the value of X .

La función messageReceived de mqtt-device ejecuta un condicional que limita el contador de Buffloc a 10, y cuando es mayor lo resetea a 0. Si lo cambio a un número X, me permite recibir más mensajes, hasta llegar al valor de X .


also within mqtt-subscribe I have to modify with the same number within the evaluate function, the for conditional

además dentro de mqtt-subscribe tengo que modificar con el mismo numero dentro de la funcion evaluate, la condicional del for.

Instead of changing these values, what could I implement so that when it reaches the maximum number of input messages allowed, it continues to show the messages?

¿en vez de cambiar estos valores, que podria implemetar para que cuando llegue al numero maximo de mensajes de entrada permitidos, siga mostrando los mensajes?

The only options I can think of:

  1. Change the hard-coded value to allocate more memory & process more messages
  2. Dynamically allocate memory & process all messages (runs the risk of running out of memory during execution)
  3. Process messages more frequently so they don’t have a chance to back up (this has its limits if there are a lot of messages sent quickly). In some cases, it might be possible to slow the incoming messages, but that might not generally be practical. A faster Arduino model might be of help, but still has limits.
  4. It might be possible to accept only limited number of messages & process them before going back to pull more messages. I don’t know if this protocol allows for specifying how much gets received; I’m guessing it doesn’t since the original code did not use it, but maybe it was just programmed “good enough”…This doesn’t work if messages are being sent asynchronously & get lost if not captured as they are sent.

Thanks gweimer, I’m using google translate, unfortunately I don’t know English, I hope the translation doesn’t change much what I want to convey, which Google translate usually does.
Well, I have very basic knowledge of C++, and of the arduino framework somewhat more extended, but basic too, the question is that, for example, the parse-json patch has a node for RST that executes clearTimeout(ctx); and restarts the timeout, but the program continues to work.
Could you implement a RST button to clear the buffer in mqtt-subscribe, so that when the buffer is full it starts from scratch without interruptions?

I have already implemented what you have told me, and I have even set the buffer to 256 messages and with a length of 256 characters, in order to receive somewhat large Json messages through mqtt, but if I do not implement a reset before the 256 messages set manually , when it reaches this figure, it will stop receiving them, I need more detailed help on how to implement a reset to mqtt-subscribe and I think also to String Buff [256][2]; //Setup buffer of mqtt-device.

Well I hope the implementation is not too difficult, and you can advise me.

All the best.

Gracias gweimer, estoy tirando de google translate, pues desafortunadamente no se ingles, espero que la traduccion no cambie mucho lo que quiero transmitir, que normalmente si lo hace google translate.
Bueno tengo los conocimientos de c++ muy basicos, y del framework de arduino algo mas extendidos, pero basicos tambien, la cuestion es que por ejemplo el patch parse-json, tiene un nodo para RST que ejecuta clearTimeout(ctx); y reinicia el timeout, pero sigue funcionando el programa.
Se le podria implementar un boton RST para limpiar el buffer en mqtt-subscribe, para que cuando se llene el buffer empieze de cero sin interrupciones?

Lo que me has comentado ya lo he implementado, e incluso he establecido el buffer a 256 mensajes y con una longitud de 256 caracteres, para poder recibir mensajes Json algo grandes mediante mqtt, pero si no implemento un reseteo antes de los 256 mensajes establecidos manualmente, cuando llegue a esta cifra, dejara de recibirlos, necesito ayuda mas detallada de como implenetar un reset a mqtt-subscribe y creo que tambien a String Buff [256][2]; //Setup buffer de mqtt-device.

Bueno espero que no sea muy dificil la implementacion, y me puedas aconsejar.

Un saludo.

The solution is to change in mqtt-device, the conditional if(Buffloc = 10) to if(Buffloc >=10).

I don’t know if it is a programming error, but since the buffer is never less than 10 in other parts of the code, the buffer was not reset
The question that now when reaching 10, the counter starts again from zero and works without restrictions of mqtt input messages

La solucion es cambiar en mqtt-device la condicional if(Buffloc = 10) por if(Buffloc >=10).

No se si es un error de programacion, pero al nunca ser el buffer menor que 10 en otras partes de codigo, pues no se reseteaba el buffer
La cuestion que ahora al llegar a 10, el contador empieza otra vez de cero y funciona sin restricciones de mensajes de entrada mqt.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.