Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when socket is closed #19

Open
anetor46 opened this issue Jul 29, 2024 · 1 comment
Open

Panic when socket is closed #19

anetor46 opened this issue Jul 29, 2024 · 1 comment

Comments

@anetor46
Copy link

anetor46 commented Jul 29, 2024

Hello,

When the socket is getting closed for any reason, the send method panic due to the call of the unwrap method:

thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/binance_spot_connector_rust-1.1.0/src/tokio_tun>
called `Result::unwrap()` on an `Err` value: AlreadyClosed

self.socket.send(message).await.unwrap();

Would it be possible to change this behaviour to avoid a panic, it might be complex to catch and make it difficult to build a robust service. Ideally while receiving message from the websocket it should return an Error in the result of the next() method of the connection object when this happen, allowing to rebuild the connection property and not crash the service.

@alplabin
Copy link
Contributor

Hey,
When you say closed for any reason, do you mean that the WebSocket stream returned an error that closed the connection? Do you have a way to reproduce this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants