Unity SDK Socket.Closed reason

  1. Versions: Nakama {3.20}, {Docker}, {unity-sdk 3.11}
  2. Server Framework Runtime language: TS/JS

Hello, this may be a repeat of this topic here: Get socket close reason
but I do not see any documentation or information about how to get the Socket.Closed reason (i.e. networking issues versus multiple user sessions) for the Unity Nakama client SDK.

Any and all help is appreciated.

Thank you :slight_smile:

Hi @lightning :wave:

I had a look at our WebSocket adapter based on the System.Net.WebSockets.ClientWebSocket type in the .NET standard 2.0 profile:

nakama-dotnet/Nakama/WebSocketStdlibAdapter.cs at master · heroiclabs/nakama-dotnet · GitHub

I don’t think its possible to expose the WebSocket close reason except through whatever Exception type is passed to ReceivedError event signal when we detect the error in the receive loop. What do you think? Would this be enough information for what you need?

Hello, @novabyte! :wave:

Thank you for the suggestion.

Unfortunately, when the Socket is closed when a user is on multiple clients with the session.single_socket configuration on, the ReceivedError event is not triggered - only the Closed event is triggered - so, I cannot parse the reason as to why the Socket was closed in this way :slightly_frowning_face:

Any other ideas? :sweat_smile:

Thank you again! :pray:

Well you could tehnically abuse localcache on the server, check if user is already logged in, and then upon connection or even auth, send custom error that user is already connected.
Maybe that could work.

thanks, @Eatos
from what i could glean from the other topic is that this is already implemented server-side, and it does work very well.

i just need a way to retrieve the message in the Unity client when the socket closed event occurs - it’s not exposed on the retrieval side.

does this need an update to the unity-sdk in order to work? :thinking:
or, update the server to send an error event along with the socket closed event? :thinking:

i can make an issue/ticket if that is needed. i do think it would be beneficial to folks using the library.

please let me know how to proceed. thank you :slightly_smiling_face: