Photon Voice + Photon Server = silence

Hi -

We have an app that works fine with Photon Cloud. We are trying to provide an on-premise version using Photon Server. Everything works great in the cloud but with Photon Server we can't get voice to work.

We have the server and app configured for UDP on 5055. I'm using PerfMon to see that the connections are being made and the i/o looks good. We can see the avatars for multiple users appear and move (this is a VR app). But no voice!

Change the config settings to hit the Photon Cloud instead and voice comes through loud and clear.

Stumped. Any ideas for how to troubleshoot?

Thanks -
DJD

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @djdevvydev,

    Thank you for choosing Photon!

    How do you connect to the self-hosted Photon Server?
    What do you see in the Unity editor or client logs?

    Could you try logging voice client state to make sure that the voice client is connected properly?
    You could use this snippet:
            public void OnEnable()
            {
                PhotonVoiceNetwork.Client.OnStateChangeAction = OnStateChangeAction;
            }
    
            private void OnStateChangeAction(ClientState clientState)
            {
                Debug.LogFormat("Photon Voice Client State Changed to {0}", clientState);
            }
  • Connecting via UDP on 5055. Will try the logging you suggest, thanks!
  • JohnTube
    JohnTube ✭✭✭✭✭
    I meant show me the code you use to connect client to self-hosted server.
  • When connected to the internet, the voice works.

    When I disconnect my wifi router then the voice stops. But the avatars still work.

    So it appears that though the self hosted is working, the voice is still re-routed through the cloud server.
  • blaineimeve
    edited May 2018
    Here's the code that connects to the server...
    
    setStatus( string.Format( "Connecting to Photon, version {0}...", _gameVersion ) );
    if ( config.serverIP != null ) {
             Debug.LogFormat( "ConnectToMaster {0} {1} {2} {3}", config.serverIP, config.serverPort, _appId, _gameVersion );
    	PhotonNetwork.ConnectToMaster( config.serverIP, config.serverPort, _appId, _gameVersion);
    } else {
              Debug.LogFormat( "ConnectUsingSettings {0}", _gameVersion );
    	PhotonNetwork.ConnectUsingSettings(_gameVersion);
    }
    
  • This is for voice.

    startVoice occurs when the app is started.

    createVoice is called when the client has joined a room.
    
    	void startVoice() {
    
    		UnityEngine.Object resource = Resources.Load( "AudioOutPrefab", typeof(GameObject) );
    		Debug.Log( "AudioOutPrefab resource = " + resource );
    		audioOutPrefab = resource as GameObject;
    		Debug.Log( "audioOutPrefab = " + audioOutPrefab );
    
    		PhotonVoiceNetwork.Client.OnStateChangeAction += onVoiceStateChange;
    
    	}
    
    	void createVoice() {
    
    		if ( audioOut != null )
    			return;
    
    		Debug.Log( "audioOut = PhotonNetwork.Instantiate( AudioOutPrefab, ... )" );
    		audioOut = PhotonNetwork.Instantiate( "AudioOutPrefab", new Vector3(0,0,0), Quaternion.identity, 0 );
    		Debug.Log( audioOut );
    		if ( audioOut == null )
    			return;
    
    		PhotonVoiceRecorder rec = audioOut.GetComponent();
    		if ( rec != null ) {
    			Debug.Log( "configure PhotonVoiceRecorder" );
    			rec.enabled = true;
    			rec.Transmit = true;
    			rec.Detect = true;
    			rec.DebugEchoMode = true;
    			//rec.MicrophoneDevice = Microphone.devices[0];
    		}
    
    	}
    
  • And here's a log of the client with internet connecting to voice cloud...
    onVoiceStateChange - Photon Voice Client State Changed to ConnectedToNameServer
    onVoiceStateChange - Photon Voice Client State Changed to Authenticating
    onVoiceStateChange - Photon Voice Client State Changed to DisconnectingFromNameServer
    onVoiceStateChange - Photon Voice Client State Changed to ConnectingToMasterserver
    onVoiceStateChange - Photon Voice Client State Changed to Authenticating
    onVoiceStateChange - Photon Voice Client State Changed to Joining
    onVoiceStateChange - Photon Voice Client State Changed to ConnectedToMaster
    onVoiceStateChange - Photon Voice Client State Changed to DisconnectingFromMasterserver
    onVoiceStateChange - Photon Voice Client State Changed to ConnectingToGameserver
    onVoiceStateChange - Photon Voice Client State Changed to Authenticating
    onVoiceStateChange - Photon Voice Client State Changed to Joining
    onVoiceStateChange - Photon Voice Client State Changed to Joined




  • Self hosted server only, disconnected internet so can't contact the cloud...

    PUNVoice: Timeout-disconnect! Command: CMD(2 c#:255 r/u: 1/0 st/r#/rt:9391/6/10047) now: 19000 challenge: 787f796
    onVoiceStateChange - Photon Voice Client State Changed to Disconnected
    PUNVoice: Got a unexpected Disconnect in LoadBalancingClient State: Disconnected. Server: MasterServer Trace: at ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient.OnStatusChanged(StatusCode statusCode) in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:line 2249
    at ExitGames.Client.Photon.PeerBase+<>c__DisplayClass146_0.b__0()
    at ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands()
    at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands()
    at ExitGames.Client.Photon.PhotonPeer.Service()
    at ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient.Service() in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:line 873
    at ExitGames.Client.Photon.Voice.LoadBalancingFrontend.Service() in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:line 124
    at PhotonVoiceNetwork.Update() in C:\Imeve\ImevoAvatarAVPro\Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:line 268
    onVoiceStateChange - Photon Voice Client State Changed to Disconnected
  • @JohnTube any other info needed? Is there any special configuration needed to tell Voice that it should talk to the self hosted server instead of the cloud?
  • JohnTube
    JohnTube ✭✭✭✭✭
    your code snippet shows that you are connecting PUN to the self-hosted server manually and connecting the voice client to the cloud.
    I suggest you make use of PUN's ServerSettings and always use ConnectUsingSettings and change Hosting Option/Type from Unity Editor.
    Or disable Voice's AutoConnect from VoiceSettings and manually connect voice client (when PUN is connected or when PUN is joined) using the available methods mentioned here.
  • @JohnTube am I able to change the settings at load time? I have a requirement that I need to be able to configure the app to either use cloud or self hosted, or TCP or UDP, via a configuration .json file on the Android/Windows device.

    I think I was trying to change the value for transport to TCP/UDP, but it had already done some initialization and things got confused.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2018
    You could in theory change settings at runtime by changing ServerSettings from code.
    e.g.
    PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.SelfHosted;
                PhotonNetwork.PhotonServerSettings.ServerAddress = serverAddress;
                PhotonNetwork.ConnectUsingSettings(_gameVersion);
    Or you could disable Voice's AutoConnect and handle Voice client connection manually like you do for PUN (PhotonNetwork.ConnectToMaster), use this:
    PhotonVoiceNetwork.Client.Connect(masterServerAddress, null, null, nickname, authValues);
    Photon Cloud supports UDP only for Voice applications because we think that's better for voice chat.
    You could switch TCP for self-hosted Photon Server though, change protocol in "PhotonVoiceNetwork.cs":

    from
    PhotonVoiceNetwork()
        {
            client = new UnityVoiceFrontend(ConnectionProtocol.Udp);
        }
    
    to
    PhotonVoiceNetwork()
        {
            client = new UnityVoiceFrontend(ConnectionProtocol.Tcp);
        }
    However, you could still use TCP for PUN and UDP for Voice.
  • And here's a log without internet, just the self hosted local server.

    PUNVoice: Timeout-disconnect! Command: CMD(2 c#:255 r/u: 1/0 st/r#/rt:9391/6/10047) now: 19000 challenge: 787f796
    ...
    ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands()
    ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands()
    PhotonVoiceHandler:Update() (at Assets\PUNVoice\Scripts\PhotonVoiceHandler.cs:165)

    (Filename: Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs Line: 393)

    onVoiceStateChange - Photon Voice Client State Changed to Disconnected
    ...
    PhotonManager:onVoiceStateChange(ClientState) (at Assets\PhotonManager.cs:752)
    UnityVoiceFrontend:OnStateChange(ClientState) (at Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:570)
    ExitGames.Client.Photon.Voice.LoadBalancingFrontend:onStateChangeVoiceClient(ClientState) (at Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:304)
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:set_State(ClientState) (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:334)
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:2303)
    ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands()
    ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands()
    PhotonVoiceHandler:Update() (at Assets\PUNVoice\Scripts\PhotonVoiceHandler.cs:165)

    (Filename: Assets/PhotonManager.cs Line: 752)

    PUNVoice: Got a unexpected Disconnect in LoadBalancingClient State: Disconnected. Server: MasterServer Trace: at ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient.OnStatusChanged(StatusCode statusCode) in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:line 2249
    at ExitGames.Client.Photon.PeerBase+<>c__DisplayClass146_0.b__0()
    at ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands()
    at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands()
    at ExitGames.Client.Photon.PhotonPeer.Service()
    at ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient.Service() in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:line 873
    at ExitGames.Client.Photon.Voice.LoadBalancingFrontend.Service() in C:\Imeve\ImevoAvatarAVPro\Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:line 124
    at PhotonVoiceNetwork.Update() in C:\Imeve\ImevoAvatarAVPro\Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:line 268
    ...
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:2251)
    ExitGames.Client.Photon.<>c__DisplayClass146_0:b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:Service()
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Service() (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:873)
    ExitGames.Client.Photon.Voice.LoadBalancingFrontend:Service() (at Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:124)
    PhotonVoiceNetwork:Update() (at Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:268)

    (Filename: Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs Line: 393)

    onVoiceStateChange - Photon Voice Client State Changed to Disconnected
    ...
    UnityVoiceFrontend:OnStateChange(ClientState) (at Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:570)
    ExitGames.Client.Photon.Voice.LoadBalancingFrontend:onStateChangeVoiceClient(ClientState) (at Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:304)
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:set_State(ClientState) (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:334)
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:2257)
    ExitGames.Client.Photon.<>c__DisplayClass146_0:b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:Service()
    ExitGames.Client.Photon.LoadBalancing.LoadBalancingClient:Service() (at Assets\Plugins\PhotonLoadbalancingApi\LoadBalancingClient.cs:873)
    ExitGames.Client.Photon.Voice.LoadBalancingFrontend:Service() (at Assets\Plugins\PhotonVoiceApi\LoadBalancingFrontend.cs:124)
    PhotonVoiceNetwork:Update() (at Assets\PUNVoice\Scripts\PhotonVoiceNetwork.cs:268)

    (Filename: Assets/PhotonManager.cs Line: 752)
  • JohnTube
    JohnTube ✭✭✭✭✭
    I don't know if the voice client succeeds to connect to the self-hosted Photon server then gets an unexpected timeout disconnect or if the voice client's initial attempt to connect to Photon server times out.

    Could you give us the lines that start with "onVoiceStateChange" only from logs of voice client connecting to self-hosted Photon Server?

    Also, you could check out server logs and see what's wrong. (e.g. this or this)
    And you could also log server address (PhotonVoiceNetwork.client.CurrentServerAddress, maybe in the "onVoiceStateChange" callback), and add more log entries here and there to help you debug this.