SSLStream Failure with .Net 4.x in Unity 2018.1

When Unity 2018.1 was released I jumped (perhaps too quickly) to using “.Net 4.x Equivalent” for the scripting runtime version under “Build Settings->Player Settings.”

Everything ran fine in the Unity Editor, but socket reads would silently fail after a few seconds on iOS.

I use SSLStream and SSLStream.Read() in a while loop running under its own thread. This runs without any issue using IL2CPP under the .Net 3.5 runtime, but fails almost immediately under iOS using 4.x.

I’m not sure what the exact problem is, but a forum post on unity.com seems to indicate that TLS related functions aren’t going to be fully ready using the .Net 4.x runtime and IL2CPP until 2018.2:
https://forum.unity.com/threads/questions-around-tls-support-on-2018-1.524917/

Either way, if you come across this issue, simply reverting back to .Net 3.5 seems to resolve the problem.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.