apoelstra / rust-jsonrpc

Rust JSONRPC library
Creative Commons Zero v1.0 Universal
158 stars 62 forks source link

simple_http: handle sockets returning "connection reset on peer" errors #90

Closed philipr-za closed 1 year ago

philipr-za commented 1 year ago

It was observed via CI that on Mac OS a broken socket could sometimes return the error "Connection reset by peer" on the attempt to read or write when the socket was closed. This behavior was not observed on the *nix and Windows CI jobs but it is a valid behavior. Currently the socket is detected as broken when no bytes are returned by the read call.

This PR adds in logic handling the case that when the first write and read operations happen if there was an error then a fresh socket is requested and the write and follow up read is attempted a second time. If the second write and read errors then the error is returned.

apoelstra commented 1 year ago

Nice!, thanks.