Our game records some of the gameplay, which I then want to upload to our Playfab CDN as an accessible replay for other users. I am hosting a custom game server via the Multiplayer Legacy Servers service as an intermediary to verify the replay data and authorise it being sent on to the CDN.
The server is a Unity Server build which listens for upload request via an HttpListener, the client, when appropriate, attempts to send the replay data (~100kb) via a UnityWebRequest.Put.
The flow works fine, the CDN can receive the files and other clients can download and replay them. However, only when I am running the server on my local windows machine. When I package a build and upload it to the Legacy Servers service, whilst the flow works correctly, the binary data is incorrect.
For debug purposes, I am writing out two files. One at the last moment before sending the UnityWebRequest and one immediately after receiving the file on the server. These two files do not match. Whilst they are largely the same and contain the same number of bytes, a diff of the two files shows a number of discrepancies scattered throughout.
An example of the client send:
var www = UnityWebRequest.Put(url, data); // where data is byte[] www.SetRequestHeader("Content-Type", "application/octet-stream"); File.WriteAllBytes(path, www.uploadHandler.data); var asyncOperation = www.SendWebRequest(); // etc
An example of the server receive:
var listener = (HttpListener)result.AsyncState; var context = listener.EndGetContext(result); var request = context.Request; var response = context.Response; var stream = new MemoryStream(); request.InputStream.CopyTo(stream); File.WriteAllBytes(path, stream.ToArray());
Is there something about the environment hosting the Legacy Servers that I need to be taking into account for my data to work correctly?