mikerochip/unity-websocket

More websocket closing stuff

Closed this issue · 1 comments

Hi Mike,

I didn't realize when I responded to the email, it went to the existing github issues page.

I had 2 additional requests:

  1. I use desktop builds to intermittently test multiplayer issues since they build faster than web builds. I haven't pinned down the details yet, but when I try to close out the desktop build (e.g., clicking on the system close button while the websocket is connected) I was getting the handshake exception thrown on my server which was in the middle of a receiveasync. I attempted to detect the close in the Unity app and call disconnect before shuttting down, but it doesn't help for me. Is it possible it the websocket disposes itself (ungracefully) when it thinks shutdown is imminent? Also, I do this on linux, so not sure if that is a factor or not.

  2. I'm doing a similar trick for the unity editor. Detecting stop and disconnecting the websocket DOES work, but the minor problem is that I have to wait a little bit before allowing the editor to actually exit play mode. I suspect the websocket doesn't do anything until the next Update() frame. So while I have a working solution, it is a bit sub-optimal, as I suspect the websocket library could theoretically issue the closeoutputasync (or whatever it needs to do) immediately, at least specially cased for exiting the editor.

I somehow felt guilty actually going through github to communicate this (I wanted this to be off the record :) ) but I suppose this is the proper channel of communication.

Thanks for the previous fixes.
-Brian

Had a longer, less readable, more opinionated reply here that I removed, which I don't think was as helpful or reflects the outcome I'd want, so apologies for that. For posterity:

For issues where it's a request for a different behavior preference

  1. Opening a PR to demonstrate the behavior differences is the most helpful to have a concrete back and forth
  2. Providing specifics also helps e.g. exceptions, error codes, sample code, repro steps, etc.

Re: for seeking help managing robust client shutdown behavior

  1. Unity APIs like Application.wantsToQuit and others
  2. Forum posts like this one
  3. Implementing a custom exit button that calls Application.Quit() after other shutdown tasks may help

Re: exception handling for server-side .NET WebSockets

Just something that has to be done IMO, see this response from the previous issue or how my own test server does it