[erlang-questions] inets - http:request with invalid host (Per Hedeland)
Ingela Anderton Andin
Fri Jun 1 08:45:13 CEST 2007
> "Sanjaya Vitharana" <> wrote:
>> Attached are the traces. But still I can't find why this happens.
> Uh, why what happens, precisely? As far as I have understood (which
> could of course be wrong), you are knowingly making a request to a
> non-existent IP address?
I was under the impression that he did that accidentally and still got
the behavior that
he did not expect, but I could be mistaken too! Regardless I think that
in this special case
it would be better to change the behavior of the client so that it in
the asynchronous case does not
get delayed by the tcp timeout.
> If so, you should of course expect it to fail.
> The TCP/IP stack will give up - i.e. time out - the connect() operation
> after a "pretty long time". Exactly how long depends on a lot factors,
> too many to go into here - a bit over one minute is common, but it can
> also be significantly more (or less).
> Of course it could be argued that http:request/4 should pass the 8
> second timeout that you give it onto gen_tcp:connect/4, instead of
> calling gen_tcp:connect/3 which in your case (per above) proceeds to
> hang for 3 minutes before it fails - and in the async case spawn the
> gen_tcp:connect/4 instead of waiting for it to complete.
The http client uses the timeout applied to the whole request process
rather than just the setup,
but in this particular case I agree that it would be a good idea to pass
it even to gen_tcp:connect as it unfortunately will block the other
Regards Ingela - OTP team
More information about the erlang-questions