checksum0 / go-electrum

A pure Go ElectrumX JSON-RPC library.
MIT License
27 stars 26 forks source link

Fix shutdown method and make it public. Implement configurable timeouts #3

Closed thomasstevens89 closed 2 years ago

thomasstevens89 commented 4 years ago

Electrumx does automatically close idle connections as per https://electrumx.readthedocs.io/en/latest/environment.html#envvar-SESSION_TIMEOUT

However if you're opening a lot of connections at the same time, say in a multi-threaded application such as a HTTP server/handler, then it very easy to hit the SESSION_LIMIT. Control over closing the underlying connection is important in this scenario.

This PR makes the shutdown() method publicly callable. It also fixes the shutdown process to properly close the underlying TCP transport connection. Finally, it implements configurable connection and request timeouts