-
Notifications
You must be signed in to change notification settings - Fork 5
add MQTT_MAX_RETRY_FOR_AVAILABLE_FOR_WRITE directive to check the eth… #58
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
base: master
Are you sure you want to change the base?
Conversation
…ernet client has enough space in the write buffer to sent the entire MQTT message (publish&subscribe)
Nope, this is using This will be the code (with small modifications) for these. I didn't have had the time yet to make a PR for it, but will do now..... |
In #57 (comment) you wrote that it fails to work after several (long?) messages. Can you please provide a small example that I can test it on a ESP82866 (only device I have / use) to see it it fails there as well. But ... this looks to me more like a bug in QNEthernet lib, as it does not flush it's buffer if it's full. There was a discussion regarding performance and write behavior in ssilverman/QNEthernet#93 ... |
Just be a bit careful when calling |
@TD-er Thanks for the hint. You may be absolutely right. There are so many different client implementations and they may vary. This is the reason why I want an example. Maybe we really only need it for QNEthernet (or discuss with the guys there what we should do best). |
Thanks for the lively discussion here! I can only imagine that some implementation indeed will erase the current write buffer... (which is what you would expect for an input stream). Let's try to answer below, but I want to stress that if you do not define It is a bunch of small messages, but I was also subscribing, so while I fixed the publish, the subscribe action as still suffering from the same issue. (So some of my comments originate from the time before I understood this) As discussed above, it depends on the underlaying ethernet client implementation how things are really working. I believe you are right to question what the right way is. For now I can live with what I have currently, so I'm good for now. Nevertheless, I would love to see a release, or some recommendation on how to handle this in a clean way. |
Well there are several possible ways to go and fix your issue, but I do think that (nearly?) all end up with a big question mark on what's going on with your networking device. PubSubClient does typically handle every message (in/out) as a single transaction. An example of an error is when your message header states there will be a message of N bytes and your message is of different size. These are the main limitations of the MQTT protocol (at least 3.x version, I have not yet looked into version 5.x). What I do think has to be done (and what you also try to do and I also with my PR) is that the buffer should be made more flexible. However when we need to take several buffer sizes into account, we might need to consider using a circular buffer or else you keep moving data in the pubsubclient buffer to the front. A drawback of using a circular buffer is that you don't have a guaranteed continuous array of bytes when feeding the topic and message to a callback function. TL;Dr
|
…ernet client has enough space in the write buffer to sent the entire MQTT message (publish&subscribe)
As described in issue #57