Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question UnityWebRequest error Cannot connect to destination host

Discussion in 'Scripting' started by EVI_TD, Jul 3, 2023.

  1. EVI_TD

    EVI_TD

    Joined:
    May 1, 2022
    Posts:
    4
    Hello guys,

    Im trying to do a get Request to a server using Unity web request but im getting a "Cannot connect to destination host" error.

    The URL is working in a browser but it simply fails everytime from unity. The URL that im trying to get is classified by the browser as not secure so Im not sure if this could cause this error.

    Code (CSharp):
    1. IEnumerator descargarListaServidores(){
    2.  
    3.         UnityWebRequest www = UnityWebRequest.Get("xxx.xxx.xxx.xxx:14100/infoServidor");
    4.         yield return www.SendWebRequest();
    5.        
    6.         if (www.result != UnityWebRequest.Result.Success) {
    7.             Debug.Log(www.error);
    8.         }else {
    9.             textoListaDeServidores = www.downloadHandler.text;
    10.             Debug.Log(textoListaDeServidores);
    11.         }
    12.         yield return null;
    13.     }
    upload_2023-7-3_10-10-31.png
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    If thos 'x' characters are the IP address, then your URL is missing the http:// prefix.