Suvitruf Suvitruf - 3 months ago 54
C# Question

Https client for WebGL build in Unity3d

I need https client for WebGL build.

WWW is horrible. First of all, it doesn't support keep-alive connections, plus it has problems with https.

UnityWebRequest doesn't support keep-alive.

There is plugin for WebSockets by Unity team, but it was last updated year ago.

For other platforms I have wrote custom solution based on raw sockets (C#

TcpClient
), but
UnityEngine.Network
namespace isn't supported in WebGL build.

Any suggestions?

Answer

Looks like UnityWebRequest is fine now. In Unity 5.3 it was in experimental namespace and it literally haven't worked.

In Untiy 5.4 this class was moved to UnityEngine.Networking and seems stable. And, surprisingly, it has support for keep-alive connection. So, for WebGL build I can use it (at least with Unity >= 5.4).

Note: for WebGL build your server should set CORS headers. Also, your server should support OPTIONS requests.

Comments