Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

How long is the WWW timeout?

Discussion in 'Scripting' started by Staples, Jan 5, 2012.

  1. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    To my understanding we can't set the timeout associated with WWW, however I was just wondering how long is the built in timeout?

    Can't seem to find it in the docs.

    Thanks!
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    That is correct, you can not set it.
    The documentation does not mention it cause it totally depends on the platform.

    WWW always uses the platforms native path to HTTP communcation, so within browsers it uses the browsers HTTP pipe for example, on standalone it uses an own tcp based implementation, on iOS it uses the NSURLConnection etc
    Each of them has own limits etc.

    On standalone it is 10s if I recall right until it must receive something at latest or the connection is considered to be time outed.


    One thing to mention though: If you want to have a shorter timeout you can always set that! You can use WWW.Dispose() (as WWW implements IDisposable) to kill a WWW request before its done.
     
  3. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Hmm thanks, shouldn't it be somewhat dependant on the server then? When I use XHMLHttp requests from javascript I can have timeouts of many minutes if I desire, providing the server allows it.


    Also since things like tcp and even NSURLConnection allow a timeout to be specified, why don't they just let us set it if desired?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    The server puts up an additional timeout yes but thats a timeout that will only trigger in if the connection was successful at first at all and that impacts for how long it will remain valid (important if you want to offer large files through WWW from your webserver, in that case you will likely need to adjust the PHP config)


    As for why its not possible: can't comment on that. I would guess cause its easier to not offer it if the exact behavior depends on platform. Unity exposes the things that are crossplatform only normally
     
  5. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Nope. Sadly not on my 2 Android devices. Seems like the default timeout on those Android 4.x devices (using Unity 4.2.1) when connecting to a given IP:port address (where no http service is listening at, but the ip itself is pingable/reachable) is 60 seconds which is way too long, but not only this, Dispose holds out for the timeout to expire! Yes, that's right and that's not cool at all. I'm talking about a WWW request whose progress will stall at 0 because the given address will not accept the tcp connection --- I can "manually time-out" this after say 5 seconds but only if I don't call Dispose(). If I do, that very call waits the full 60 seconds!

    Not sure if that's new behavior, a bug or Android-specific --- but felt I should mention this. I have to hope for www to clean up properly without Dispose in this one-off case if I don't want the app to wait the full 60s.
     
    elenzil likes this.