Error on disconnect

Hi, I'm making a mobile game that allows you to continue in single player mode if a multiplayer game ends prematurely. However, if internet connectivity is lost, I get an endless stream of errors from PhotonVoiceNetwork which affects performance. I'm currently solving it with:
public override void OnDisconnected(DisconnectCause cause)
	if (Photon.Voice.PUN.PhotonVoiceNetwork.Instance != null)
But I'm curious if that causes issues if someone's connection flickers, or if there's a way Voice can handle this error a little more gracefully? Here's the full error:
DNS.GetHostEntry() failed for: Exception: System.Net.Sockets.SocketException (0x80004005): Could not resolve host ''
  at System.Net.Dns.Error_11001 (System.String hostName) [0x00015] in <14e3453b740b4bd690e8d4e5a013a715>:0 
  at System.Net.Dns.GetHostByName (System.String hostName) [0x00021] in <14e3453b740b4bd690e8d4e5a013a715>:0 
  at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00052] in <14e3453b740b4bd690e8d4e5a013a715>:0 
  at ExitGames.Client.Photon.IPhotonSocket.GetIpAddresses (System.String hostname) [0x00023] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\IPhotonSocket.cs:299 
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2304)
ExitGames.Client.Photon.<>c__DisplayClass108_0:<EnqueueDebugReturn>b__0() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:899)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:434)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771)
Photon.Voice.Unity.VoiceConnection:Dispatch() (at Assets/Photon/PhotonVoice/Code/VoiceConnection.cs:398)
Photon.Voice.Unity.VoiceConnection:FixedUpdate() (at Assets/Photon/PhotonVoice/Code/VoiceConnection.cs:381)


  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @lmartell,

    I see.
    What is the disconnect cause here?

    You could fix this using a proper solution not a workaround if you know why the client got disconnected in the first place.

    - If both clients PUN 2 and Photon Voice 2 disconnect then this should not happen
    - If Photon Voice 2 disconnects and PUN 2 does not (unexpected), Photon Voice 2 will keep retrying to reconnect if PhotonVoiceNetwork.Instance.AutoConnectAndJoin is true
    - If PUN 2 enters offline mode, this depends on PhotonVoiceNetwork.Instance.WorkInOfflineMode

    so I would adjust values PhotonVoiceNetwork.Instance.AutoConnectAndJoin and PhotonVoiceNetwork.Instance.WorkInOfflineMode. maybe at compile time or change them on the fly at runtime.
    log disconnect cause(s).
    maybe have a retry attempts threshold after which you stop.

    You could also explicitly try calling PhotonVoiceNetwork.Instance.Disconnect.
  • I first ran across the error when my router crashed, but after that I was simulating it just by disabling my network adapter, so disconnect cause is just "Exception." If I disconnect the cable then cause is "Client Timeout" after a few seconds, which is what I'd expect. The repeating error is the same in either case.

    I actually had some issues updating the voice plugin last week... I'm on 2.18 before WorkInOfflineMode was added, but started a separate thread for that and circle back once that's working.