Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang. Asynchronous http request. How to know when connection is broken?

Making an asynchronous request to some server using the httpc HTTP client

httpc:request(get, {Url, []}, [], [{sync, false}, {stream,
self}])

where Url is the URL of the server. Data is received by handle_info/2 in gen_server that called httpc:request/4 but I should get message when the connection is broken and there is no stream_end message. Using timeout is not feasible for me, because server response can take a long time.

Is it possible to get message about a broken connection in handle_info/2? If not, please suggest way to know when the connection is broken?

like image 555
Artem Golovinsky Avatar asked Jan 07 '11 00:01

Artem Golovinsky


1 Answers

For more heavy-duty lifting of HTTP requests, use ibrowse:

https://github.com/cmullaparthi/ibrowse

It has many more knobs to twist and turn for requests and is more complete w.r.t. many things. If http/httpc doesn't solve your problem, it is worth investigating if going to ibrowse will.

like image 89
I GIVE CRAP ANSWERS Avatar answered Oct 14 '22 17:10

I GIVE CRAP ANSWERS