-
Notifications
You must be signed in to change notification settings - Fork 103
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
Problem of unnecessary waiting time for reception #261
Comments
Offhand, this looks like expected behavior to me. If you are receiving more than one byte from the transport interface, then blocking may happen. In this case it looks like it does happen. Are you somehow requesting only a single byte when getting to the end of the OTA packets? Phrased differently - Why is this idle time unexpected? Why shouldn't it appear here? |
Hi kstribrnAmzn, thank you for your reply. My explain was not good, the single byte check was performed by CoreMQTT v1. The MQTT Agent and CoreMQTT v1 did below process, then we could skip the waste wait for waiting the receive data untile timeout.
https://freertos.github.io/coreMQTT/v2.1.1/group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167 However, v2 of CoreMQTT requests 5KB data without checking of 1byte packet if the data is comming or not. |
This behavious is related to OTA update. I faced the same issue. With core-mqtt v1, when requesting to read a single byte, the receive implement may block a timeout priod(mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS- I dont remember exactly the config). And I applied it to core-mqtt v2.1.1, it did not work properly because core-mqtt v2 does not request a single byte anymore. Next question : Is this material fixed? As my understanding, core-mqtt v2 does not request a single byte anymore. |
Any update for this issue? |
@KeitaKashima, @VanNamDinh thank you for your patience. I didn't mean to keep you waiting so long. The notifications slipped by me. I'm going to tag my coworker, @AniruddhaKanhere, in this reply as he was one of the most significant contributors in CoreMQTT v2. I'm hoping he'll keep my answer honest. Unfortunately our documentation is misguiding. "However, v2 of CoreMQTT requests 5KB data without checking of 1byte packet if the data is comming or not. The single byte packet read of CoreMQTT v1 was removed as this encouraged packet fragmentation. With CoreMQTT v2.0.0+ the MQTT packet is returned only when the entire MQTT packet has been read from the transport interface. Edit: "bytes" not "bites" |
I will create a PR updating the documentation here. The transport receive function should no longer block in any condition. This method should return whatever bytes it has (this could be anywhere from 0 to the requested amount). CoreMQTT will then assemble the MQTT packet out of the received bytes and return it when complete. Any bytes from the next MQTT packet will remain in the CoreMQTT buffer until all bytes needed for that packet have been received. |
@kstribrnAmzn said:
I would like to make a small correction. coreMQTT v2 tries to read as many bytes as possible and then parses all the data that it received from the network interface. In case the library receives an incomplete packet (same as above - 50 bytes out of 100), the error code MQTTNeedMoreBytes is returned to let the caller know that MQTTProcessLoop should be called again so that the remaining packet can be retrieved from the transport interface. |
Corrections highlight the non-blocking expectations of the TransportRecv method. Inspired by - FreeRTOS#261
Corrections highlight the non-blocking expectations of the TransportRecv method. Inspired by - FreeRTOS#261
Corrections highlight the non-blocking expectations of the TransportRecv method. Inspired by - FreeRTOS#261
Description ----------- Corrections highlight the non-blocking expectations of the TransportRecv method. Test Steps ----------- No manual steps taken. I'm going to let the doxygen CI verify this. Checklist: ---------- <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ X ] I have tested my changes. No regression in existing tests. - Testing with CI - [ X ] I have modified and/or added unit-tests to cover the code changes in this Pull Request. - Not applicable Related Issue ----------- #261 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Thank you for your reply.
I got the right policy not to wait for the received data in the However, the I thought this wait time was for waiting comming the data when we called the Where should the wait time of TLS_FreeRTOS_Connect be affected? https://www.freertos.org/mqtt/server-authentication-mqtt-example.html |
Hello @KeitaKashima, I recommend separating both the timeout values in the call to |
Hello @KeitaKashima, I take it from your reaction (👍) to my post that the above issue is resolved. I shall be closing this thread. If you'd feel that the issue persists or the solution was not satisfactory, please feel free to reopen this thread or open a new one. |
Hi @AniruddhaKanhere , Yes, I could solve the issue by following your idea. So I think it is okay to close this ticket. |
I use the FreeRTOS-LTS 2022210.01.
I realized that CoreMQTT had a idle period every data paket of OTA when I do OTA of FreeRTOS.
I doesn't happen when I use previsou version of LTS of FreeRTOS of CoreMQTT ver 1.
It affects the period of OTA because the wast idle time in here.
Below figure is the waveform I got do the OTA using FreeRTOS v202210.01 with CoreMQTT v2.
As you can see the idle period is here at the end of OTA packets.
I checked why this issue is happned, then the below code is requested the Receive API not to check the total packet size.
Then, the Receive API is waiting until timeout, because the recevied packet size is smaller than the upper API requested.
coreMQTT/source/core_mqtt.c
Line 1685 in 03290fe
CoreMQTT receive API says the a byte recevie doesn't block. So we have implemeted it.
But V2 of CoreMQTT happened avobe issue.
https://freertos.github.io/coreMQTT/v2.1.1/group__mqtt__callback__types.html#ga227df31d6daf07e5d833537c12130167
The text was updated successfully, but these errors were encountered: