You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell, there's no way to receive a callback when the socket used by SocketConnection is closed or disposed. I'd like to make a proxy server which accepts connections using a proprietary protocol, unpacks the messages from that protocol, and sends the content on to another server. I'll end up with two SocketConnections, and a class which is translating between them. When one SocketConnection is closed, I need to close the other one to ensure I'm not leaking connections.
I could include a 'disconnect' message in the protocol, but that doesn't handle network errors or application errors
I could poll the SocketConnection, but that seems too hacky
Ideally, I'd like to register a callback, or be able to await a task, so I can run some cleanup code once either of the two sockets has disconnected.
The text was updated successfully, but these errors were encountered:
andrewjw1995
changed the title
Unable to await socket closure
Unable to wait for socket closure
Aug 16, 2020
@xqrzd that makes more sense - I was waiting for ReadAsync() to return a status of canceled or completed, but it was throwing an exception instead. The documentation for PipeReader does not indicate that this method can throw an exception, so I was not handling it. I think perhaps the readme for this repo could be updated to show how to make a basic proxy, as it's a very simple use case and it would demonstrate where network exceptions need to be caught, for both PipeReader and PipeWriter
As far as I can tell, there's no way to receive a callback when the socket used by SocketConnection is closed or disposed. I'd like to make a proxy server which accepts connections using a proprietary protocol, unpacks the messages from that protocol, and sends the content on to another server. I'll end up with two SocketConnections, and a class which is translating between them. When one SocketConnection is closed, I need to close the other one to ensure I'm not leaking connections.
Ideally, I'd like to register a callback, or be able to await a task, so I can run some cleanup code once either of the two sockets has disconnected.
The text was updated successfully, but these errors were encountered: