OSError: [Errno -29312] MBEDTLS_ERR_SSL_CONN_EOF

  • There is this line in urequests

    s=socket.socket(); s.connect(ai); s=ssl.wrap_socket(s, server_hostname=host)

    that has been working great with multiple programs for over a year now. Recently, after a few trivial changes unrelated to urequest calls in the calling progam, it has started throwing OSError: [Errno -29312] MBEDTLS_ERR_SSL_CONN_EOF. The main program makes multiple calls to requests & it's always the last one that has the error, the others work fine.

    https://stackoverflow.com/questions/51160692/esp32-micropython-ssl-websocket suggests inserting import gc; gc.collect() a few lines above the wrap_sockets line after the dns lookup but that hasn't fixed it.

    I'd be grateful for some suggestions on what to try next.

  • @kjm that error normally means that the remote server shut down the connection.

    Are all your calls to the same server? Do you get the same result if you do the calls independently or reorder them? What do curl or openssl s_client say when performing the same request(s)?

    Make sure you log the actual request being sent (full URL including protocol, host, port, path, query, as well as method, headers, body sent if relevant...) and double check that it all matches what you expect.

    If you can, it would be interesting to capture the relevant traffic (on the server or an intermediate router) to see what exactly is sent by the server.

Log in to reply

Pycom on Twitter