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

Connection.IsOpen returning true after closing it #17

Open
Thranduillion opened this issue Oct 19, 2016 · 2 comments
Open

Connection.IsOpen returning true after closing it #17

Thranduillion opened this issue Oct 19, 2016 · 2 comments

Comments

@Thranduillion
Copy link

Thranduillion commented Oct 19, 2016

Hi,

I have a problem with the IsOpen method in Xamarin Forms (PCL)

Everything is going well but when I check if the connection is open it always return true even after closing it.

I have two buttons :
First one is for opening connection :

private void Button5_Clicked(object sender, EventArgs e)
{
            connection = Websockets.WebSocketFactory.Create();
            connection.OnOpened += Connection_OnOpened;
            connection.OnClosed += Connection_OnClosed;
            connection.Open("http://192.168.0.11:3000/user1");
}

The other for closing connection :

private void Button4_Clicked(object sender, EventArgs e)
{
            connection.Close();
}

I checked if the connection is open in the OnClose method :

private void Connection_OnClosed()
{
            Debug.WriteLine("Connection closed");
            Debug.WriteLine("IsOpen : " + connection.IsOpen); //return true
}

Thanks for your help

@ghost
Copy link

ghost commented Feb 27, 2017

I get the same results, IsOpen is unreliable. Inspecting the source code reveals why.

@chrisweihu
Copy link

Has anyone fixed this bug yet? I am having the same issue here, only it only happens on iOS. In addition, the Connection_OnClosed() is never triggered when web socket connection is lost.
Thanks

chrisweihu pushed a commit to chrisweihu/Websockets.PCL that referenced this issue Aug 22, 2017
Bug Fix NVentimiglia#17 - Connection.IsOpen returning true after closing it
NVentimiglia#17
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