- Home /
HTTPS (SSL) initial connection timeout bug
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!
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: $$anonymous$$ono.Security.Protocol.Tls.TlsException: Couldn't complete EndRead at $$anonymous$$ono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) [0x00000] in :0 at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) [0x00000] in :0 at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols sslProtocolType, Boolean checkCertificateRevocation) [0x00000] in :0 at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost) [0x00000] in :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
Can we bump this up? We have the exact same errors and issues as you guys
Well, everyone who can reproduce this bug should file a detailed bugreport in Unity. UnityAnswers isn't a place to report bugs as this site is mainly run by the community and not the Unity staff. The more people complain about an issue that can be reproduced the more likely it is to get a fix.
When you file a bug report make sure you include as much information as possible. Where your server is located (LAN / WAN) if you have other software that connects to the same server without the problem. Attach an example project which they can be used to reproduce the problem. Do you actually have a valid SSL certificate (+provider) or do you go the "hacky" route? Any known hardware in between the endpoints? (Firewall, NAPT-router, load-balancer, ...)
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?