Hello! I have an ongoing project, it’s a project where I make a query to a database via PHP. The project is running 24/7 on a PC, but every day I see an error log saying: “Cannot resolve destination host”. It happens approximately every 20 hours, and even if I restart the scene, the error persists. The only solution is to close and reopen the program.
I know it’s a bit odd; I ran tests in our office and it throws the same error.
I don’t have any performance issues, and the internet connection is stable
For additional context, I’m using Unity 6, the hosting is on Hostmonster, and it’s a project for PC.
What I don’t understand is why I have to restart the executable to make it work again.
Here is the code:
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class DataChecker : MonoBehaviour
{
[SerializeField] string phpName = "checkData.php";
public IEnumerator RequestUserInfo(string idIndex, Action<string> OnSuccess, Action<string> OnError)
{
yield return StartCoroutine(RequestUserInfoCoroutine(idIndex, OnSuccess, OnError));
}
IEnumerator RequestUserInfoCoroutine(string idIndex, Action<string> onSuccess, Action<string> onError)
{
WWWForm form = new WWWForm();
form.AddField("id", idIndex);
string url = StaticIPs.server + "/" + phpName;
using (UnityWebRequest www = UnityWebRequest.Post(url, form))
{
www.certificateHandler = new CertificateServer();
www.downloadHandler = new DownloadHandlerBuffer();
www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
{
onError?.Invoke(www.error);
}
else
{
string jsonResult = www.downloadHandler.text;
onSuccess?.Invoke(jsonResult);
}
}
}
}
Best regards!