Hi all,
I have an issue where the send() function will occasionally hang. Is it better to use nrf_send() instead?
Thanks,
Chris
Hi all,
I have an issue where the send() function will occasionally hang. Is it better to use nrf_send() instead?
Thanks,
Chris
I’ve experienced this in the past but usually it was at a higher level (using the MQTT client). I would make sure that you’re calling that send
command from a friendly context (main loop is a good place) and keep it consistent. I’ve often locked up network clients because of underlying contention (often calling the send command from different threads/contexts)
Hope that helps!
jaredwolff
Hm, okay. I am sending 40kB of data to the cloud every 15-20 seconds and I fragment the HTTPS into 8 chunks. When sending each chunk there is a small chance the code gets locked up and hangs in the send function. The code stops executing as if it were in an infinite loop, but my interrupts continue to work. Trying to debug this and it has been a lot of effort with no real progress.
That could be the problem right there. I would make sure that whatever data is sent before pushing the next chunk.
I’ve also had issues in the past where the outgoing transmission thread was referencing static data. If that static data changes mid-strea (i.e. you copied in the next chunk before the client has flushed the data) that could cause issues. It depends though on the underlying HTTP client and how the sockets are handled.
jaredwolff The TLS buffer is max 2048 bytes and I am currently running a do/while loop sending 800 bytes at a time. This do/while loop is repeated 8 times for 8 fragments. The first buffer always sends with no issues no matter the size. The problem only occurs on the next 7 (no consistently and randomly).
I am sending the ZSOCK_MSG_DONTWAIT
flag. As some pseudocode, I do a send for 800 bytes, if the send fails with a return value of “-1”, I increase offset by one to counteract the -1 return and try to resend the same amount of bytes. Upon success, we move onto the next 800 bytes and repeat until the end of the buffer.
How would I 100% check to see if the send is complete? I don’t have access to any flags or registers inside of the modem to look at. I believe the send function only returns when it is complete with the bytes sent.
cchoi22915 maybe you can dive into the CoAP or MQTT implementation and see how other implementations handle sending data. I rarely work with raw sockets like you are.
What thread/context are you doing this do/while loop in?