The modem trace shows, that you don't enable DTLS 1.2 CID.
As long as you don't use a "private network" (e.g. IPsec Tunnel or VPN from your mobile provider to your server), your IP traffic will go through something similar a NAT and that removes the public address mapping after a quiet phase. The next message are then mapped to a new source address and that fails to decrypt on the server side. DTLS 1.2 CID overcomes that.
Check, if your server supports CID. Maybe just by enable it in the modem with
int cid = NRF_SO_SEC_DTLS_CID_SUPPORTED;
err = setsockopt(sock, SOL_TLS, TLS_DTLS_CID, &cid, sizeof(cid));
(I'm not sure, if this is still well, it was that with NCS 2.4.0).
and test, if that already works with your server.
Otherwise you may close your socket after the transfer and reopen it on the next transfer. Though you have anyway a lot of data, the additional handshake doesn't make it worse.
a 33kB file in 17 x 2kB chunks
CoAP blockwise (RFC 7959) doesn't support 2k blocks (1k max), as UDP would usually also not support that without UDP fragmentation, which is considered to be not too reliable.
Hello Achim,
Many thanks for your response. Apologies for the delay in responding - I was on vacation.
I have confirmed that adding DTLS CID has fixed the issue! We are using the Californium as our server by the way and it worked without any server changes.
I didn't explain the upload size very well - I meant that we are sending a 33kB file in 17 individual CoAP transactions. Each transaction is sending 2kB data, but using block-wise chunks of 512 bytes. So each transaction contains 4 blocks. We re-assemble the file on the server manually. This was chosen to limit the amount of RAM we need to store the data before uploading (it is sent from the main processor to nRF9151 in 2kB chunks).
Thanks a lot for your input and expertise - saved me a lot of debugging
Jason
Hello Achim,
Many thanks for your response. Apologies for the delay in responding - I was on vacation.
I have confirmed that adding DTLS CID has fixed the issue! We are using the Californium as our server by the way and it worked without any server changes.
I didn't explain the upload size very well - I meant that we are sending a 33kB file in 17 individual CoAP transactions. Each transaction is sending 2kB data, but using block-wise chunks of 512 bytes. So each transaction contains 4 blocks. We re-assemble the file on the server manually. This was chosen to limit the amount of RAM we need to store the data before uploading (it is sent from the main processor to nRF9151 in 2kB chunks).
Thanks a lot for your input and expertise - saved me a lot of debugging
Jason
You're welcome.