Internal server error on big block-wise transfer
Hi,
I'm using libcoap (v4.3.0-rc2) to transfer files from sensors, those files can be quite big (up to 20 MB). Trying out the block-wise feature with observers, I came accross a "maximal size" : 16,777,215 kB, as I'm receiving 5.00 everytime a GET request is received and answered with a resource with a size2 bigger than this value. My code is adjusted from the minimal example . Here are the logs of my server and client :
Server :
May 20 18:14:24.607 DEBG ***[::1]:5683 <-> [::1]:36151 (if1) UDP : new incoming session
May 20 18:14:24.607 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : received 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:24.607 DEBG call custom handler for resource 'hello'
May 20 18:14:24.607 DEBG create new subscription
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:24.607 DEBG ** [::1]:5683 <-> [::1]:36151 (if1) UDP : lg_xmit 0x5585fbc52550 initialized
May 20 18:14:24.607 DEBG PDU presented by app
v:1 t:ACK c:2.05 i:0000 {} [ Observe:0, Content-Format:text/plain ] :: binary data length 16777216
<<#START_OF_CORRECT_PAYLOAD#>>
May 20 18:14:35.778 DEBG invalid option length
v:1 t:ACK c:2.05 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: binary data length 1024
<<#START_OF_CORRECT_PAYLOAD#>>
May 20 18:14:35.778 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : sent 1039 bytes
v:1 t:ACK c:2.05 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: binary data length 1024
<<#START_OF_CORRECT_PAYLOAD#>>
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : received 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:35.779 DEBG call custom handler for resource 'hello'
May 20 18:14:35.779 DEBG invalid option length
May 20 18:14:35.779 DEBG removed observer with token ''
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : sent 36 bytes
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : received 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:35.779 DEBG call custom handler for resource 'hello'
May 20 18:14:35.779 DEBG create new subscription
May 20 18:14:35.779 DEBG invalid option length
May 20 18:14:35.779 DEBG removed observer with token ''
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : sent 36 bytes
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : received 4 bytes
v:1 t:RST c:0.00 i:0000 {} [ ]
May 20 18:14:35.779 DEBG * [::1]:5683 <-> [::1]:36151 (if1) UDP : received 4 bytes
Client :
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:24.607 DEBG * [::1]:36151 <-> [::1]:5683 UDP : sent 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:24.607 DEBG ** [::1]:36151 <-> [::1]:5683 UDP : mid=0x0: added to retransmit queue (2531ms)
May 20 18:14:27.138 DEBG ** [::1]:36151 <-> [::1]:5683 UDP : mid=0x0: retransmission #1
May 20 18:14:27.138 DEBG * [::1]:36151 <-> [::1]:5683 UDP : sent 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:32.200 DEBG ** [::1]:36151 <-> [::1]:5683 UDP : mid=0x0: retransmission #2
May 20 18:14:32.200 DEBG * [::1]:36151 <-> [::1]:5683 UDP : sent 11 bytes
v:1 t:CON c:GET i:0000 {} [ Observe:0, Uri-Path:hello ]
May 20 18:14:35.778 DEBG * [::1]:36151 <-> [::1]:5683 UDP : received 1039 bytes
v:1 t:ACK c:2.05 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: binary data length 1024
<<#START_OF_CORRECT_PAYLOAD#>>
May 20 18:14:35.779 DEBG ** [::1]:36151 <-> [::1]:5683 UDP : mid=0x0: removed
v:1 t:ACK c:2.05 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: binary data length 1024
<<#START_OF_CORRECT_PAYLOAD#>>
May 20 18:14:35.779 DEBG * [::1]:36151 <-> [::1]:5683 UDP : received 36 bytes
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
May 20 18:14:35.779 DEBG * [::1]:36151 <-> [::1]:5683 UDP : sent 4 bytes
v:1 t:RST c:0.00 i:0000 {} [ ]
May 20 18:14:35.779 DEBG * [::1]:36151 <-> [::1]:5683 UDP : received 36 bytes
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
v:1 t:ACK c:5.00 i:0000 {} [ ETag:0x01, Observe:0, Content-Format:text/plain, Size2:16777216 ] :: 'Internal Server Error'
May 20 18:14:35.779 DEBG * [::1]:36151 <-> [::1]:5683 UDP : sent 4 bytes
v:1 t:RST c:0.00 i:0000 {} [ ]
Thanks for your work and I hope I've been clear enough.
Best,
The following fix is needed for libcoap-minimal client.cc (but is not your primary issue) so that message ids are properly tracked.
diff --git a/client.cc b/client.cc
index b5f0a58..f225b8b 100644
--- a/client.cc
+++ b/client.cc
@@ -44,7 +44,7 @@ main(void) {
/* construct CoAP message */
pdu = coap_pdu_init(COAP_MESSAGE_CON,
COAP_REQUEST_CODE_GET,
- 0 /* message id */,
+ coap_new_message_id(session),
coap_session_max_pdu_size(session));
if (!pdu) {
coap_log( LOG_EMERG, "cannot create PDU\n" );
The issue is reproducible and need to debug it. There is a RFC7959 limitation of about 1G in size.
The fix is in PR #683 for your reported situation.
Just tried your fix and it's working. Thanks for your work.