Arm Mbed OS support forum

MbedTLS with Mongoose errors after finished data transfer

Hi guys,

I’m using Mongoose 7.3 from Cesanta with builtin mbed TLS 3.0.0 for my API server. Client is written using C# and using Webclient with https protocol. Generated pair of key+ cert and succesfully implemented them in api server, communication is going well, but after data transfered I have so many retries every 1 second, you can see them on the below. Mongoose returns err = 11, it means EAGAIN (Try again) in linux system. Errors are displayed during 100 seconds. Hint: ServicePointManager.MaxServicePointIdleTime in client is also seto to 100 seconds.

Best regards, Pls help.

It look like this:

mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:42    mongoose.c:2834:read_conn 8   00100100000010       0 0/512 err 11

Full log:

2021-07-21 02:11:37    Net: EVENT MG_EV_ACCEPT
2021-07-21 02:11:37    mongoose.c:3515:mg_tls_in 8 Setting TLS, CA: -, cert: pms.crt, key: pms.key
mbedtls/ssl_tls.c:5060 |2| => handshake
mbedtls/ssl_srv.c:4263 |2| server state: 0
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:4263 |2| server state: 1
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:1145 |2| => parse client hello
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 153
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 153
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 148 (-0xffffff6c)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_srv.c:1899 |2| selected ciphersuite: TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384
mbedtls/ssl_srv.c:1933 |2| <= parse client hello
mbedtls/ssl_srv.c:4263 |2| server state: 2
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:2458 |2| => write server hello
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 96, out_left: 96
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 96 (-0xffffffa0)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_srv.c:2661 |2| <= write server hello
mbedtls/ssl_srv.c:4263 |2| server state: 3
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_tls.c:1702 |2| => write certificate
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 584, out_left: 584
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 584 (-0xfffffdb8)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_tls.c:1783 |2| <= write certificate
mbedtls/ssl_srv.c:4263 |2| server state: 4
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:3262 |2| => write server key exchange
mbedtls/ssl_srv.c:3068 |2| ECDHE curve: x25519
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 177, out_left: 177
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 177 (-0xffffff4f)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_srv.c:3346 |2| <= write server key exchange
mbedtls/ssl_srv.c:4263 |2| server state: 5
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:2697 |2| => write certificate request
mbedtls/ssl_srv.c:2711 |2| <= skip write certificate request
mbedtls/ssl_srv.c:4263 |2| server state: 6
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:3354 |2| => write server hello done
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 9, out_left: 9
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 9 (-0xfffffff7)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_srv.c:3382 |2| <= write server hello done
mbedtls/ssl_srv.c:4263 |2| server state: 7
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_tls.c:2305 |2| => parse certificate
mbedtls/ssl_tls.c:2310 |2| <= skip parse certificate
mbedtls/ssl_srv.c:4263 |2| server state: 8
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:3702 |2| => parse client key exchange
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 42
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 42
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 37 (-0xffffffdb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:3775 |2| <= read record
mbedtls/ssl_tls.c:1306 |2| => derive keys
mbedtls/ssl_tls.c:1451 |2| => calc verify sha384
mbedtls/ssl_tls.c:1459 |2| <= calc verify
mbedtls/ssl_tls.c:1363 |2| <= derive keys
mbedtls/ssl_srv.c:3994 |2| <= parse client key exchange
mbedtls/ssl_srv.c:4263 |2| server state: 9
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:4033 |2| => parse certificate verify
mbedtls/ssl_srv.c:4045 |2| <= skip parse certificate verify
mbedtls/ssl_srv.c:4263 |2| server state: 10
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_msg.c:4749 |2| => parse change cipher spec
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 6
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 6
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 1 (-0xffffffff)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:3775 |2| <= read record
mbedtls/ssl_msg.c:4800 |2| <= parse change cipher spec
mbedtls/ssl_srv.c:4263 |2| server state: 11
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_tls.c:2892 |2| => parse finished
mbedtls/ssl_tls.c:2656 |2| => calc  finished tls sha384
mbedtls/ssl_tls.c:2682 |2| <= calc  finished
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 45
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 45
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 40 (-0xffffffd8)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1212 |2| => decrypt buf
mbedtls/ssl_msg.c:1716 |2| <= decrypt buf
mbedtls/ssl_msg.c:3775 |2| <= read record
mbedtls/ssl_tls.c:2960 |2| <= parse finished
mbedtls/ssl_srv.c:4263 |2| server state: 12
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_msg.c:4726 |2| => write change cipher spec
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 6, out_left: 6
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 6 (-0xfffffffa)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_msg.c:4740 |2| <= write change cipher spec
mbedtls/ssl_srv.c:4263 |2| server state: 13
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_tls.c:2781 |2| => write finished
mbedtls/ssl_tls.c:2656 |2| => calc  finished tls sha384
mbedtls/ssl_tls.c:2682 |2| <= calc  finished
mbedtls/ssl_msg.c:2392 |2| => write handshake message
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:529 |2| => encrypt buf
mbedtls/ssl_msg.c:951 |2| <= encrypt buf
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 45, out_left: 45
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 45 (-0xffffffd3)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:2521 |2| <= write handshake message
mbedtls/ssl_tls.c:2879 |2| <= write finished
mbedtls/ssl_srv.c:4263 |2| server state: 14
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_srv.c:4368 |2| handshake: done
mbedtls/ssl_srv.c:4263 |2| server state: 15
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1978 |2| <= flush output
mbedtls/ssl_tls.c:5071 |2| <= handshake
2021-07-21 02:11:38    mongoose.c:3465:mg_tls_ha 8 success
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 160
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 160
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 155 (-0xffffff65)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1212 |2| => decrypt buf
mbedtls/ssl_msg.c:1716 |2| <= decrypt buf
mbedtls/ssl_msg.c:3775 |2| <= read record
mbedtls/ssl_msg.c:5400 |2| <= read
2021-07-21 02:11:38    Net: EVENT MG_EV_HTTP_MSG
2021-07-21 02:11:38    Sql: Opened database successfully
2021-07-21 02:11:39    Authentication: USER LOGGED!
2021-07-21 02:11:39    mongoose.c:2974:mg_connec 1 -> udp://192.168.1.10:514
2021-07-21 02:11:39    mongoose.c:2890:close_con 1 closed
2021-07-21 02:11:39  I mongoose.c:2249:mg_mgr_fr All connections closed
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:39    mongoose.c:2834:read_conn 8   00100100000011       0 0/512 err 11
mbedtls/ssl_msg.c:5487 |2| => write
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:529 |2| => encrypt buf
mbedtls/ssl_msg.c:951 |2| <= encrypt buf
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 171, out_left: 171
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 171 (-0xffffff55)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:5511 |2| <= write
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 5, nb_want: 124
mbedtls/ssl_msg.c:1932 |2| in_left: 5, nb_want: 124
mbedtls/ssl_msg.c:1933 |2| ssl->f_recv(_timeout)() returned 119 (-0xffffff89)
mbedtls/ssl_msg.c:1953 |2| <= fetch input
mbedtls/ssl_msg.c:1212 |2| => decrypt buf
mbedtls/ssl_msg.c:1716 |2| <= decrypt buf
mbedtls/ssl_msg.c:3775 |2| <= read record
mbedtls/ssl_msg.c:5400 |2| <= read
2021-07-21 02:11:39    Net: EVENT MG_EV_HTTP_MSG
2021-07-21 02:11:39    Sql: Opened database successfully
2021-07-21 02:11:39    Authentication: USER LOGGED!
2021-07-21 02:11:39    mongoose.c:2974:mg_connec 1 -> udp://192.168.1.10:514
2021-07-21 02:11:39    mongoose.c:2890:close_con 1 closed
2021-07-21 02:11:39  I mongoose.c:2249:mg_mgr_fr All connections closed
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:39    mongoose.c:2834:read_conn 8   00100100000011       0 0/512 err 11
mbedtls/ssl_msg.c:5487 |2| => write
mbedtls/ssl_msg.c:2544 |2| => write record
mbedtls/ssl_msg.c:529 |2| => encrypt buf
mbedtls/ssl_msg.c:951 |2| <= encrypt buf
mbedtls/ssl_msg.c:1966 |2| => flush output
mbedtls/ssl_msg.c:1986 |2| message length: 421, out_left: 421
mbedtls/ssl_msg.c:1991 |2| ssl->f_send() returned 421 (-0xfffffe5b)
mbedtls/ssl_msg.c:2019 |2| <= flush output
mbedtls/ssl_msg.c:2685 |2| <= write record
mbedtls/ssl_msg.c:5511 |2| <= write
#####################################
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:40    mongoose.c:2834:read_conn 8   00100100000010       0 0/512 err 11
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:41    mongoose.c:2834:read_conn 8   00100100000010       0 0/512 err 11
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:42    mongoose.c:2834:read_conn 8   00100100000010       0 0/512 err 11
mbedtls/ssl_msg.c:5206 |2| => read
mbedtls/ssl_msg.c:3701 |2| => read record
mbedtls/ssl_msg.c:1750 |2| => fetch input
mbedtls/ssl_msg.c:1907 |2| in_left: 0, nb_want: 5
mbedtls/ssl_msg.c:1932 |2| in_left: 0, nb_want: 5
2021-07-21 02:11:43    mongoose.c:2834:read_conn 8   00100100000010       0 0/512 err 11