Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connections are never closed #11

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

connections are never closed #11

jclopes opened this issue Sep 24, 2010 · 10 comments

Comments

@jclopes
Copy link

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
Copy link
Owner

Have you tried using the inactivity_timeout option?

@jclopes
Copy link
Author

jclopes commented Sep 24, 2010

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

@cmullaparthi
Copy link
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
Copy link
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
Copy link
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
Copy link
Author

jclopes commented Sep 25, 2010

I'll give it a try. thanks

@jclopes
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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

@jclopes
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants