connections are never closed #11

Closed
jclopes opened this Issue Sep 24, 2010 · 10 comments

Projects

None yet

2 participants

@jclopes
jclopes commented Sep 24, 2010

ibrowse never timesout on a open connection if the server never closes the connection.
This will cause an application that connects to several different domains to eventually exhaust all file descriptors.

I suggest the use of some sort of argument to explicitly pass a timeout in seconds or infinity to a send_req.
The connection should be closed after the timeout has expired.

@cmullaparthi
Owner

Have you tried using the inactivity_timeout option?

@jclopes
jclopes commented Sep 24, 2010

no I haven't where and how should I set this option?

@cmullaparthi
Owner

It was supposed to be used like this.

ibrowse:send_req(Host, Port, Method, Headers, [{inactivity_timeout, 5000} | Other_options]).

But it only works if a request is in progress. But that is a bit silly, it should work even if all requests on that connection are done and the connection is idle. I'll make a patch and let you know. Thanks for reporting it.

@cmullaparthi
Owner

Here is a patch against ibrowse-2.0.1

The connection will close after 10 seconds of inactivity on the connection. You can control this timeout value by the ibrowse application variable inactivity_timeout (either set in ibrowse.app or your sys.config file)

http://pastebin.com/download.php?i=emBiTfcZ

@cmullaparthi
Owner

The updated patch at the link below supports specifying this config in ibrowse.conf as well.

http://pastebin.com/download.php?i=cNe10QEj

@jclopes
jclopes commented Sep 25, 2010

I'll give it a try. thanks

@jclopes
jclopes commented Sep 27, 2010

I applyed your patch but I get this error:

** When Server state == undefined
** Reason for termination == 
** {function_clause,[{ibrowse_http_client,do_close,[undefined]},
                 {ibrowse_http_client,terminate,2},
                 {gen_server,terminate,6},
                 {proc_lib,init_p_do_apply,3}]}

looks like the state is being set to undefined somewhere.

@jclopes
jclopes commented Sep 27, 2010

I added this two lines to the set_inac_timer/2 to solve the problem:

+set_inac_timer(State, infinity) ->
+    State;

After some debugging I noticed that get_inac_timeout/1 was returning infinity and that would cause set_inac_timer/2 to return 'undefined'.

let me know if this is the right way to solve the problem.
Thanks

@cmullaparthi
Owner

That's great, thanks very much. I'll commit it soon...

@jclopes
jclopes commented Sep 30, 2010

It works thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment