NotSocket Error 10038 on MagicLeap

Options
Hello,

I'm developing an application on the MagicLeap platform using Unity 2019.2.
In the application I often get a NotSocket error code 10038 at the first re-connection.

Given the circumstances of our app, we have the following sequence:
We first enter a lobby and then a named room. Here we interact with another user and generate a specific room name for these users. After this both clients leave the room, join the lobby again and from there join the room of the specific name. We receive the onjoinedroom() event.
However after this we receive an exception. Here's the stacktrace:


11-26 11:23:50.553 2224 1 E Unity : Receive issue. State: Connected. Server: '92.38.154.45' ErrorCode: 10038 SocketErrorCode: NotSocket Message: The descriptor is not a socket System.Net.Sockets.SocketException (0x80004005): The descriptor is not a socket
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.Playables.PlayableDirector.SendOnPlayableDirectorStop () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Net.Sockets.Socket.Receive (System.Byte[] buffer) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at ExitGames.Client.Photon.SocketUdp.ReceiveLoop () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ThreadHelper.ThreadStart () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.GridLayout.DoNothing () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.Playables.PlayableDirector.SendOnPlayableDirectorStop () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.Playables.PlayableDirector.SendOnPlayableDirectorStop () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : at UnityEngine.Playables.PlayableDirector.SendOnPlayableDirectorStop () [0x00000] in <00000000000000000000000000000000>:0
11-26 11:23:50.553 2224 1 E Unity : System.Diagnostics.StackTrace:init_frames(Int32, Boolean)
11-26 11:23:50.553 2224 1 E Unity : System.Diagnostics.StackTrace:.ctor(Int32, Boolean)
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.StackTraceUtility:ExtractStackTrace()
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.GridLayout:DoNothing()
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.Logger:Log(LogType, Object)
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.Debug:LogError(Object)
11-26 11:23:50.553 2224 1 E Unity : Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
11-26 11:23:50.553 2224 1 E Unity : ExitGames.Client.Photon.<>c__DisplayClass104_0:b__0()
11-26 11:23:50.553 2224 1 E Unity : ExitGames.Client.Photon.MyAction:Invoke()
11-26 11:23:50.553 2224 1 E Unity : ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
11-26 11:23:50.553 2224 1 E Unity : ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
11-26 11:23:50.553 2224 1 E Unity : Photon.Pun.PhotonHandler:Dispatch()
11-26 11:23:50.553 2224 1 E Unity : Photon.Pun.PhotonHandler:FixedUpdate()
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.GridLayout:DoNothing()
11-26 11:23:50.553 2224 1 E Unity : UnityEngine.GridLayout:DoNothing()


Any pointer to what could go wrong here?
Thanks in advance,
best regards,
Chris

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2019
    Options
    Hi @christosaurus, (nice dinosaur name btw)

    Thank you for choosing Photon!

    Does this happen in the Unity Editor or in a build?

    Otherwise:
    What PUN version are you using?
    Is this 100% reproducible?
  • Hello,

    This is running on an Lumin OS (Android 64) build of our project. (Btw. we also see problems connecting between a Windows and a Android64 build, but this is not important for us. Just as an info: should the connection between different platforms work?)

    We're using PUN 2.15 Photon lib: 4.1.2.18

    Not sure about the 100% as I just got to the project but I can't remember a moment it worked on the first connect. After the second connection, the socket error does not appear anymore until the application is started again.
  • Some more relevant info on this:
    - this happens after the call to PhotonNetwork.LoadLevel(1) in the master client.
    - AutomaticallySyncScene is set to true
    - The script game object that holds the networking code and the PhotonView object is held as a static game object and is set to DontDestroyOnLoad.
    - After the first socket exception, the subsequent connection attempts work after the LoadLevel() call.

    Thanks in advance.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @christosaurus,

    How often does this happen?
    Do you confirm this does not happen in the Unity Editor?
    Did you test this on a different ML device?
    Did you test this on a different network?
    Does it happen on all clients or just the master client who calls LoadLevel?

    It's not easy for me to try to reproduce with the info you shared:

    at the first re-connection.
    by 're-connection' you mean:

    - joining a room for a second time?
    - switching servers (from master server (lobby) to game server (room) or opposite?)
    - reconnect after explicit disconnection
    - reconnect after unexpected disconnection

    After the first socket exception, the subsequent connection attempts work after the LoadLevel() call.

    Not sure I got the "timing" and "occurrence" thing here.
    So once you get the exception, you can get it only after closing and re-opening the app again?

    So steps are (from first post):

    - connect
    - join lobby
    - join room by name from lobby
    - leave room
    - join lobby
    - join room by name from lobby

    or (last post)

    - connect
    - join room
    - call LoadLevel

    Btw. we also see problems connecting between a Windows and a Android64 build, but this is not important for us. Just as an info: should the connection between different platforms work?
    Photon is cross platlform. If you have an issue in matching two clients, take a look at our "Matchmaking Checklist".
  • christosaurus
    edited December 2019
    Options
    JohnTube said:

    Hi @christosaurus,

    How often does this happen?

    By now I'm off the impressions it happens every time, at least I haven't seen a clean run in a while,

    Do you confirm this does not happen in the Unity Editor?
    Currently I cannot completely confirm this, I'll have to get back to you on this

    Did you test this on a different ML device?
    Yes, we've tested this on at least 5 devices

    Did you test this on a different network?
    Yes, I can see this behavior on our company's network as well as on other wireless networks

    Does it happen on all clients or just the master client who calls LoadLevel?
    I always see it on the master client, on other clients I see the error occasionally otherwise I see indications that the connection is lost.


    It's not easy for me to try to reproduce with the info you shared:

    at the first re-connection.
    by 're-connection' you mean:

    - joining a room for a second time?
    - switching servers (from master server (lobby) to game server (room) or opposite?)
    - reconnect after explicit disconnection
    - reconnect after unexpected disconnection

    I guess a reconnection after the socket error. So basically unexpected but recovered within the application. See below.



    After the first socket exception, the subsequent connection attempts work after the LoadLevel() call.

    Not sure I got the "timing" and "occurrence" thing here.
    So once you get the exception, you can get it only after closing and re-opening the app again?

    So steps are (from first post):

    - connect
    - join lobby
    - join room by name from lobby
    - leave room
    - join lobby
    - join room by name from lobby

    or (last post)

    - connect
    - join room
    - call LoadLevel

    The Photon dependent steps toward the error are:
    Connect to master
    Join Lobby
    Join Room "Meetup"
    Select one of available players and handshake a private room name ("User1_User2")
    Leave room (both users)
    Rejoin lobby (both users)
    Join Room ("User1_User2")
    Call LoadLevel to activate the game scene.

    LoadLevel is the last Photon call before the error occurs

    So after the socket error occurs the various callbacks lead us back to our main menu. After this, we go through all the steps again and this time the loadLevel call succeeds without an error.

    After closing the application and restarting it on the device, the same error occurs again

    Btw. there is a reason for our way of matching users via the two rooms concept, so I don't think that we can use another method here for the moment

    And also thanks for providing help on these convoluted descriptions :)
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @christosaurus,

    Thanks for answering all my questions.

    If you build for Mono / .NET4.x, you could try switching the socket implementation.

    In "Assets\Photon\PhotonRealtime\Code\LoadbalancingPeer.cs", inside ConfigUnitySocket, replace:
                #if NET_4_6 && (UNITY_EDITOR || !ENABLE_IL2CPP)
                this.SocketImplementationConfig[ConnectionProtocol.Udp] = typeof(SocketUdpAsync);
                this.SocketImplementationConfig[ConnectionProtocol.Tcp] = typeof(SocketTcpAsync);
                #endif
    with:
    
                this.SocketImplementationConfig[ConnectionProtocol.Udp] = typeof(SocketUdpAsync);
                this.SocketImplementationConfig[ConnectionProtocol.Tcp] = typeof(SocketTcpAsync);
     
    Try reproducing with it.
  • Unfortunately we have to compile for 64bit, which only allows the use of IL2CPP. So I guess this is not possible then?

  • Tobias
    Tobias admin
    edited March 2020
    Options
    You can also to use the SocketUdpAsync with IL2CPP. If the implementation is better, depends a lot on Unity. Maybe a newer Unity Editor version helps / helped, too.

    Did you report to Unity?

    If you are still on this, please ping again.