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

WebSocketChannel has unexpected close code #369

Open
dan461 opened this issue May 29, 2024 · 0 comments
Open

WebSocketChannel has unexpected close code #369

dan461 opened this issue May 29, 2024 · 0 comments

Comments

@dan461
Copy link

dan461 commented May 29, 2024

I'm attempting to use the onDone() callback to detect an unexpected web socket connection loss, and I'm not seeing a consistent close code. I don't know if this is a bug with the plugin, or if I'm doing something wrong. When intentionally closing the connection at the end of a session I call myChannel.sink.close(1000). When I check the channel's close code in my onDone callback I get either 1000 or 1005. I'm expecting 1000 and not 1005 and don't understand why why I would be getting that. I'm not sure if this is unexpected plugin behavior or if it's the peer on the other end not returning a consistent code. Does the channel's close code get set to the code returned by the server, or should it match what I used when closing the sink? Is there a better way to detect a dropped connection?

Here's an example of the callback
`
void _handleOnDone() {

if(_channel.closeCode != 1000){
  _onDoneCallback?.call();
}

}
`

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

1 participant