[ grinder-Bugs-2501418 ] Handle socket lingering properly ("address in use" problem)

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.java.grinder.devel
Message-ID <[email protected]>
Bugs item #2501418, was opened at 2009-01-12 14:20
Message generated for change (Settings changed) made by philipa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=2501418&group_id=18598

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: HTTP Plugin
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Dawid Weiss (dawidweiss)
Assigned to: Philip Aston (philipa)
Summary: Handle socket lingering properly ("address in use" problem)

Initial Comment:
I believe Grinder can (and should) release client sockets as soon as possible. The following changes (applied by me locally) fix the issue with running out ephemeral ports (Windows, Linux), even with very large number of connections made.

1) Create all client sockets with lingering enabled and set to 0, plus keep alive set to false:

s.setKeepAlive(false);
s.setSoLinger(true, 0);

This occurs in a few places in the code base, so all places must be patched this way.

2) Change setSoLinger argument to 'true' in StreamDemultiplexor:

try
  { Sock.setSoLinger(true, 0); }
catch (SocketException se)
  { } 

3) The script generated by TCPProxy should release the response object by reading from it and closing the output.

    result.getInputStream().close()

Note of importance: I have not tested all possible scenarios and it may break some functionality I am not familiar with. Having said that, it worked for me very well, whereas the plain release 3.1 did not.

----------------------------------------------------------------------

>Comment By: Philip Aston (philipa)
Date: 2010-01-03 17:27

Message:
Fixed in svn:
http://grinder.svn.sourceforge.net/viewvc/grinder?view=rev&revision=4221

Will be in next release.

----------------------------------------------------------------------

Comment By: Philip Aston (philipa)
Date: 2010-01-03 16:27

Message:
Implementing suggestions as follows:

Suggestion 1): Done for the two places that plain HTTP connections are
established in HTTPConnection.

Suggestion 2): Done.

Suggestion 3): Not done. Unnecessary, since the default behaviour of
HTTPRequest is to read the response body with getData() which automatically
closess the connection.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=2501418&group_id=18598

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.