I have a program in Unity that queries a server for data. I'm completely new to this so maybe I'm doing something silly. Or maybe it's a bug in Unity? Please let me know if I'm somehow causing the error and how I might fix it. The program seems to work fine despite the error, but I want to make sure I'm not wrecking any server bandwidth or anything.
Curl error limit reached: 100 consecutive messages printed
// Trying IEnumerator to keep tool responsive. It half-helps...
public static IEnumerator SaveRtcResultsToFile(string url, string credentials, string file)
{
// Making sure I don't start a second one in parallel.
// This is called within a single-threaded frame so I don't expect any race conditions
if (InProgress) yield break;
InProgress= true;
yield return null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", "Basic " + credentials);
WebResponse response;
Stream responseStream;
XmlTextReader xr;
try
{
using (response = request.GetResponse())
{
using (responseStream = response.GetResponseStream())
{
yield return null;
FileStream xml = File.Create(file + ".xml");
byte[] buffer = new byte[BufferSize];
int read;
// Receiving XML and saving directly to an XML file
while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0)
{
xml.Write(buffer, 0, read);
yield return null;
}
xml.Close();
// [omitted code that converts the XML to a CSV]
}
}
Instance.status.progress = Status.Progress.Complete;
message = "";
}
finally
{
InProgress = false;
}
}
I believe the "curl" errors are related to Unity failing to contact its own sites (can you log into the Hub or use the Asset Store?) which essentially comes down to corporate proxy settings. We use a Proxy Auto Config (PAC) file which Unity does not currently like. So setting environment variables HTTP_PROXY and HTTPS_PROXY (as is regularly recommended) does not work when directing to the auto proxy. Instead, I had to "pick a proxy" of the available ones the script picks from which lacks redundancy and all the fine-tuning the script allows for. Further, I had to work with our IT Proxy guys to modify the proxy to both whitelist and remove authentication requirements to access *.unity.com and *.unity3d.com. Without removing authentication requirements, you can hard-code your proxy credentials in the environment variables, but it's open for all to see! After these changes, I rarely ever see curl errors and I can actually log in to both my account in the Unity Hub as well as the Unity Asset Store within Unity now.
Also, I was informed that HttpWebRequest is apparently ancient and I switched to using HttpClient which resulted in better connectivity results. I was getting "Error: Success" a lot. Your guess is as good as mine...!