• Hi folks, I have a problem that’s driving me nuts.

    When using wp_remote_post with a certain timeout, the higher the timeout is, the longer it takes to get an answer from the server.

    For example, if I use a timeout of 5 seconds, I can get the answer successfully in just a couple of seconds.

    If, on the other hand, I set the timeout to 30 seconds, it takes up to 25 seconds to get the answer

    BTW, I’m using wp_remote_post in a function that’s called via admin-ajax.php

    Any ideas?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t know for a fact, but I suspect servers respond to requests in order of closest to expiration, not first in first out. The timeout setting factors into the request expiration time, so busy servers do not respond until there is a risk of an exception being thrown, which would increase its workload.

    A shorter timeout would begin to result in an increase of exceptions and retries. The optimal setting is as short as possible with a tolerable error rate. I suspect a sophisticated communications protocol (a theoretical one, not necessarily HTTP) constantly adjusts this time for a particular connection to maximize throughput.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_remote_post and timeout’ is closed to new replies.