0
\$\begingroup\$

I have a windows VPS server and i have installed an Apache server on it. in my server I only have a simple text file that contains some few words.

My problem is that when I'm trying to sending a web request to my server by (4G sim card internet service ) for accessing to getting data from the text file , It works very slow .

Something about 30 or 50 secound ! but after first request if I try again there is no problem ! It works very fast !!! It seems This slowdown will only occur in the first connection .

But in other hand if I use WI-FI internet , there is no problem and every time I try to get data it works fast.

MY problem is only with sim card internet !

This is part of my code :

    IEnumerator Get_Data()
        {
            UnityWebRequest www = UnityWebRequest.Get(servers_Address + "file.txt?t=" + UnityEngine.Random.value);

            yield return www.Send();
            string the_Data = www.downloadHandler.text;
}

Is there any problem in my code ?

My unity version is 2017.1.1

How can i solve this issue ?

\$\endgroup\$
  • \$\begingroup\$ Can you try connecting via IP address rather than domain name? Or are you on a shared server? It seems like the problem could possibly be with DNS lookup speeds. \$\endgroup\$ – Ed Marty Mar 21 '19 at 14:06
  • \$\begingroup\$ yes I'm using ip address !!! @Ed Marty \$\endgroup\$ – iman_sh Mar 21 '19 at 16:05
  • \$\begingroup\$ If you visit the same URL in a web browser on the device how does it perform? \$\endgroup\$ – Ed Marty Mar 21 '19 at 22:36
  • \$\begingroup\$ I'm trying to open the URL with firefox browser and googlechrome and it works fine. but in unity its very slow by first request. and after first time that it take more than 40 second maybe more !!! if I push refresh button in my game it works fast but in first request its very slow !!! and if i close the app or if i reset my phone , this issue will happen again in first request... i just want to get simple 4 line text from this url !!! @Ed Marty \$\endgroup\$ – iman_sh Mar 22 '19 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.