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

Stop() doesn't work. #107

Open
jpschw opened this issue Mar 30, 2015 · 2 comments
Open

Stop() doesn't work. #107

jpschw opened this issue Mar 30, 2015 · 2 comments

Comments

@jpschw
Copy link

jpschw commented Mar 30, 2015

When I invoke the Stop() method on an instance of WebSocketServer, the connection stays open.

var server = new WebSocketServer(81, IPAddress.Any)
{
    ...
};
server.Start();
Thread.Sleep(1000);
server.Stop();
@mokeev1995
Copy link

Yep, I confirm it.
Now I'm trying to fix it. Do you have any ideas?

Because of TcpListener we need to close all connections with users, so, how to do this? Without sending command to client to break connection.

@mokeev1995
Copy link

I fix it.

as here saying:

You are responsible for closing your accepted connections separately.

so, open

Classes\UserContext.cs 

and add this code to UserContext class:

        public void Disconnect()
        {
            Context.Connection.GetStream().Close();
            Context.Connection.Close();
        }

        ~UserContext()
        {
            Disconnect();
        }

And if you collect your clients with their UserContexts then you can close all connections for each user. It should help you to stop the WebSocket server

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