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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Why WWWForm / UnityWebRequest (POST) is so Slow?

Discussion in 'Multiplayer' started by DanBarreno, Oct 25, 2018.

  1. DanBarreno

    DanBarreno

    Joined:
    Sep 12, 2016
    Posts:
    25
    I use HTTP WWWForm / UnityWebRequest to send (not real time) information and receive from my game to the server and vice versa.

    Basically the server executes a php with a light task, open and modify a plain text file of a single line or add a line to a log file. This task takes approximately between 0.15 and 0.3 seconds, since I make the HTTP Post request until I receive the server reply.

    It is a fairly cheap server where I have hosted our game web so I didn't expect a better response but then, I open Chrome network console and I see that it takes to receive .js and .css approximately between 30 and 40 ms

    So my questiong is...
    Why does an HTTP GET request for a heavier file take less time than an Unity HTTP POST?

    UnityWebRequest Doc

    Thank you :)
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,644
    Which platform is this on?

    One thing that might make it slower is 100-Continue, which is enabled by default. Try disabling it and see if there is a difference.
    A fair comparison should do the same request on both things and measure the difference.
     
  3. DanBarreno

    DanBarreno

    Joined:
    Sep 12, 2016
    Posts:
    25
    Windows
    With 'useHttpContinue' deactivated, the download time of the same file is almost the same now, it's not the case of the form sent to the .php, it's clear the server is not prepared to run a php and handle the data.

    Thank you!
     
    Last edited: Oct 26, 2018
  4. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
    A Wireshark capture would help identify where the latency exists.