- Home /
`Recv failure: Connection was reset` In editor? (platform set to Android NOT WebPlayer)
Greetings,
I've been banging my head against the wall the past few days, just before we wanted to publish an update, our server stopped responding back to give us time in UTC. Basically I have a small PHP script in our server that just 'echos' back the time in UTC, I use WWW and pass it the URL of the script and get the time back in www.text
But for some god-only-knows-what reason, the server just stopped responding never giving back the time value with the error:
Recv failure: Connection was reset
Here's my codes:
IEnumerator GetServerTimeRoutine(Action<DateTime> setTime)
{
string servicesUrl = "http://path/to/script.php";
var postUrl = servicesUrl + "?action=GetServerTime";
var www = new WWW(postUrl);
yield return www;
if (!string.IsNullOrEmpty(www.error))
{
setTime(DateTime.UtcNow);
General.Utils.DebugLog("Error getting time from server. Using DateTime.UtcNow instead. " + www.error, true);
}
else
{
DateTime currentTime;
if (!DateTime.TryParse(www.text, out currentTime))
{
setTime(DateTime.UtcNow);
General.Utils.DebugLog("[Server] Couldn't parse server time. Using DateTime.UtcNow instead: " + www.text);
}
else
{
setTime(currentTime);
}
}
}
PHP Script:
<?php
if(isset($_GET['action']) == "GetServerTime"){
date_default_timezone_set("UTC");
echo date('Y/m/d H:i:s');
}
?>
I did some research, read some people saying that I should have a 'crossdomain.xml' file in my root server folder, I did just that:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
But it had no effect whatsoever. Upon further investigation it seems that people who need this file have their build option set to WebPlayer, which mine isn't. Mine's set to Android.
I have no idea why this is happening, if anyone has any idea it would be deeply appreciated.
Thanks.
It seems that if I do multiple requests, I will eventually get a response back, it's just mostly the first one that fails. No idea why.