- Home /
WebRequests have very slow transfer speed for large uploads
In our project, we have a few use cases where we want to upload a fairly large chunk of data. For example, we may want to upload a 100-200 MB video to a web API endpoint. We've noticed that these uploads can be much slower in Unity than they should be, given our bandwidth. I typically get an average upload speed of 5 Mbps. By comparison, I can upload through a browser interface, or implement the same API calls in a normal Windows (non-Mono) .NET program, and get about 20 Mbps upload speed.
We were using UnityWebRequest to do these uploads, but recently I tried switching over to .Net's WebClient/HttpWebRequest to see if it performed any better. At first the results were promising: I was hitting the same 20 Mbps speeds. However, this was with the .NET 3.5 runtime version, and I had to hack around the TLS issues that occur with that. I then switched to .NET 4.x so we could get TLS 1.2 support. This fixed the TLS exceptions correctly, but now the upload speed is back down to a miserable ~5 Mbps.
So: why does UnityWebRequest have such slow transfer speeds? Why did HttpWebRequest get the same slowdown after the .NET upgrade? Is this a known issue, and is there a fix or workaround?
Thanks, Dan