Arm Mbed OS support forum

Mbed Libuv replace network stack hangs

Hi MbedTeam

I am replacing net_socket APIs with libuv asyc network library.
For handshake on server, I am setting bio with mbedtls_ssl_set_bio and returning MBEDTLS_ERR_SSL_WANT_READ when read callback is called by handshake function mbedtls_ssl_handshake
I am able to read 310 bytes of unwrapped data on read callback, but it hangs after that.
Is there any async net example I can refer to?

Thanks

I think was vague in explaining the steps, this what I am doing , to integrate with async libuv

  1. setting up ssl context with key, certificate and ca chain
  2. binding to a socket with libuv and listening on it
  3. on client connection, accepting it through libuv and passing on accepted libuv socket to mbedtls_ssl_set_bio(sslcntx, client, send_cb, recv_cb, NULL)
  4. calling ssl mbedtls_ssl_handshake
  5. ssl handshake calls the recv_cb with buf and len and I am passing these buf, len to readSocket of libuv and returning MBEDTLS_ERR_SSL_WANT_READ
  6. on reading from socket up to len again calling mbedtls_ssl_handshake

so after reading about 310 bytes the libuv throws EWOULDBLOCK and hangs obviously.
Am I doing anything wrong which is causing it to block?

that might be a stupid question, but are you sure libuv is suitable for embedded programming? it powers node.js so it might be a little “big” for a small 32 bit mcu.

it is not intended for usage on that kind of devices
Thanks