Using (Secure) WebSockets for Photon Voice with Photon Server

Hi,
in our scenario we have a quite restrictive network setup. Therefore we are currently testing Photon's capabilites with respect to the different communication protocols for Realtime, PUN and especially Voice. We work with Photon Server v4 (latest version).
So far we have been able to successfully use UDP, TCP and even (secure) WebSockets together with the Unity Realtime SDK and the Particle demo.
However, when it comes to Photon Voice we are stuck with UDP and TCP. While we are able to configure Secure WebSockets for Photon Voice in the Unity Editor, the protocol falls back to UDP at runtime. Looking at the method VoiceConnection.ConnectUsingSettings() it seems that Photon Voice enforces either UDP or TCP on Photon Server.

Questions:
1) Is Voice over (secure) WebSockets officially supported?
2) Regardless of the official support statement, is there any chance to get Photon Voice running with (Secure) WebSockets? How?

Thank you

Comments

  • I would be really interested in this too.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2019
    Hi @Wolfgang, @Peterz,

    Thank you for choosing Photon!

    1) Is Voice over (secure) WebSockets officially supported?

    No.

    Why do you need WSS?
    I'm guessing you want to target web platforms? WebGL?
    There are constraints for that.

    Otherwise, UDP is better for real-time communication.
    In our SDKs, WSS is not supported on all platforms, unlike UDP.

    ---

    Currently, Photon Voice is available only for Unity and it supports UDP and TCP only.
    We are working on a Photon Voice C++ SDK, e.g. to be used with Unreal Engine.

    For the web, we have nothing planned.
  • Hi @JohnTube

    thanks for your response.

    We understand that UDP is the best option for real-time communication. The reason I am asking for WSS is due to network constraints (e.g. firewall settings) that we have to handle; we are not targeting web platforms / Web GL. So we do not have to worry about WebGL constraints.

    Currently we are using the "demo-voice-minimal" from the Photon Voice 2 Unity asset with target platform "Windows". So we have access to mic and speaker.
    Even if WSS is not recommended and also not supported, what would be the necessary changes in code to get it running. This way we would be able to better understand our options and test the quality.

    Thank you
    Wolfgang
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Wolfgang,

    OK I see.

    Here is how to use WSS in Photon Voice 2:

    - download latest Photon Voice 2.12
    - use Unity 2018.2 or newer and .NET 4.x (required for TLS1.2 support)
    - add "WEBSOCKET" to "Scripting Define Symbols" in your player settings
    - replace these lines in VoiceConnection.ConnectUsingSettings:
               if (Settings.Protocol == ConnectionProtocol.Tcp)
                {
                    if (!Settings.IsMasterServerAddress)
                    {
                        if (this.Logger.IsWarningEnabled)
                        {
                            this.Logger.LogWarning("Requested protocol not supported on Photon Cloud {0}. Switched to UDP.", Settings.Protocol);
                        }
                        this.Client.LoadBalancingPeer.TransportProtocol = ConnectionProtocol.Udp;
                    }
                    else
                    {
                        this.Client.LoadBalancingPeer.TransportProtocol = ConnectionProtocol.Tcp;
                    }
                }
                else if (Settings.Protocol != ConnectionProtocol.Udp)
                {
                    if (this.Logger.IsWarningEnabled)
                    {
                        this.Logger.LogWarning("Requested protocol not supported: {0}. Switched to UDP.", Settings.Protocol);
                    }
                    this.Client.LoadBalancingPeer.TransportProtocol = ConnectionProtocol.Udp;
                }
    with
                this.Client.LoadBalancingPeer.TransportProtocol = Settings.Protocol;
    
    - set protocol to WSS.
  • @JohnTube
    Thank you, we'll try that.