websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

[ERROR] A session instance cannot be reused

Open Baker68 opened this issue 5 years ago • 3 comments

Every time a client disconnects and tries to reconnect it keeps throwing this error. I tried KeepClean and ReuseAddress but still throws the error. What can I do to give clients the option to reconnect ? Thanks in advance.

Baker68 avatar Apr 11 '19 21:04 Baker68

After set ReuseAddress=True, I can reconnect or multi-connect the server. Maybe you need provide more info.

Which way are you using to add service?

  1. public void AddWebSocketService<TBehaviorWithNew>(string path, Action<TBehaviorWithNew> initializer) where TBehaviorWithNew : WebSocketBehavior, new();
  2. public void AddWebSocketService<TBehaviorWithNew>(string path) where TBehaviorWithNew : WebSocketBehavior, new();
  3. public void AddWebSocketService<TBehavior>(string path, Func<TBehavior> creator) where TBehavior : WebSocketBehavior;

keepWalking avatar Dec 19 '19 13:12 keepWalking

I'm having this same issue with ReuseAddress = True.

Using public void AddWebSocketService(string path, Func creator) where TBehavior : WebSocketBehavior; to add the service.

Would like to add that I am using dotnet core 3.1

christopherfowers avatar Apr 24 '20 19:04 christopherfowers

Were you able to fix this? I am running into the same issue and have no idea how to fix it. I have tried ReuseAddress and KeepClean. None of them worked. I even tried doing Sessions.Close(ID). I dumped the sessions and there are none but it still complains about the re-use... The exact message is: WebSocketServer.processRequest|A session instance cannot be reused.

Worst part, I cant figure out where its coming from because there is no exception I can catch...

061909 avatar Sep 25 '23 01:09 061909