Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Website recieving no data as response

Discussion in 'Multiplayer' started by coreybeavers1999, May 4, 2022.

  1. coreybeavers1999

    coreybeavers1999

    Joined:
    May 26, 2021
    Posts:
    1
    I'm trying to get started with networking and so I have hosted a website that just echos a basic hello world and I have copy and pasted the unitywebrequest.get() example but for some reason it's always returning "Received no data in response". Here's the link for my website, http://caldyonstudio-lifesim.epizy.com/WhatsUp.php

    The code for the php is,

    <?php

    echo "What up dawg?";

    ?>

    And the script I'm using in unity is...




    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Networking;

    public class network_getMessage : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    StartCoroutine(GetMessage());
    }

    IEnumerator GetMessage()
    {
    UnityWebRequest www = UnityWebRequest.Get("http://caldyonstudio-lifesim.epizy.com/WhatsUp.php");
    yield return www.SendWebRequest();

    if (www.result != UnityWebRequest.Result.Success)
    {
    Debug.Log("Error: " + www.error);
    }
    else
    {
    // Show results as text
    Debug.Log(www.downloadHandler.text);
    }
    }
    }