Search Unity

Problem with www request

Discussion in 'Scripting' started by Soapded, Jun 14, 2019.

  1. Soapded

    Soapded

    Joined:
    Aug 17, 2014
    Posts:
    2
    Hello,

    I have a little problem with my script.

    I try to show text from .txt on web server and if script do function in debug console mostly i see this log
    <html>
    <head><title>502 Bad Gateway</title></head>
    <body>
    <center><h1>502 Bad Gateway</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

    Somtimes script good shows texts from web.

    This how looks script
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class ShowsTxT : MonoBehaviour
    7. {
    8.  
    9.     void Update()
    10.     {
    11.         StartCoroutine(DownloadChangeLog());
    12.     }
    13.  
    14.  
    15.     private IEnumerator DownloadChangeLog()
    16.  
    17.     {
    18.         WWW w = new WWW("http://************HereIsGoodWebAdress**************serverchangelog.txt");
    19.            
    20.         yield return w;
    21.  
    22.         print(w.text);
    23.  
    24.     }
    25. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    Can you check your server logs?

    Have you tried using UnityWebRequest instead of WWW? WWW is deprecated.
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    There shouldn't be a difference between UWR and WWW here. You should check for errors though.
    The problem you experience seems to be a server side issue.