Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

HTTPS (SSL) initial connection timeout bug

Discussion in 'Multiplayer' started by MikeMcDonald, Jun 30, 2015.

  1. MikeMcDonald

    MikeMcDonald

    Joined:
    Jun 3, 2015
    Posts:
    8
    We are having an issue establishing connections using SSL (https) that seemed to start occurring when we upgraded to the latest version of Unity(5.1) from 4.6.

    The first https call we make will often have to timeout once or twice before succeeding when we retry the connection - sometimes it fails to connect after several retries.

    We are using the UniWeb plugin, but we have traced the issue down to the following call:

    connection.stream = new SslStream (connection.client.GetStream (), false, ValidateServerCertificate);
    var ssl = connection.stream as SslStream;
    ssl.AuthenticateAsClient (uri.Host);​

    ssl.AuthenticateAsClient() will timeout when the bug occurs. This happens in the editor and on iOS and Android devices. The AuthenticateAsClient call is a .Net2 call that Unity is interpreting which leads me to believe the bug is with Unity. We have tried multiple ways of making the call (async, other networking plugins, etc.) yet the bug persists. We have tried against multiple servers and multiple https calls.

    Another odd correlation we see is that, when working in the editor, the initial https call will succeed the first time as we run the app throughout the day until we restart Unity and then we can reliably trigger the bug where the call will take multiple attempts before succeeding. However, The bug will also happen while working in the editor throughout the day, but it will almost always happen repeatedly within the first 10-15 minutes of opening Unity.

    We are losing customers because of this bug, any knowledge about an upcoming fix or current fix would be greatly appreciated!
     
  2. Lars-Blaabjerg

    Lars-Blaabjerg

    Joined:
    Apr 5, 2011
    Posts:
    54
    I have the same, or at least very similar, problem. After upgrading to Unity 5, SslStream.AuthenticateAsClient randomly fails.

    In the editor I get this exception:

    Mono.Security.Protocol.Tls.TlsException: Couldn't complete EndRead
    at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols sslProtocolType, Boolean checkCertificateRevocation) [0x00000] in <filename unknown>:0
    at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost) [0x00000] in <filename unknown>:0
    ...

    I don't see the same behaviour with the first call working though. For me it is random. But usually it will either not work for a period or work for a period. As if depending on some external service's availability. This is regardless of which host I try to connect to.

    This is a VERY serious issue. It completely blocks reliable use of SslStream
     
  3. tcadmin

    tcadmin

    Joined:
    Oct 5, 2015
    Posts:
    2
    We are suffering from the exact same issue and it's also occuring with Unity 4.6.

    Do you have found any alternative to SslStream?