Re: [xSocket-develop] "Address already in use" errors and a question about the connection pool
Status: Inactive
Brought to you by:
grro
|
From: Christiaan W. <cwi...@te...> - 2007-11-01 13:41:36
|
Hi Gregor, As It turns out, this is not a bug, but just plain and simple TCP behavior! I checked netstat, and it showed me a shitload of dead sockets to the webserver, all in the TIME_WAIT state. The sockets will stay in this state for about 240 seconds, and in that time, you cannot reuse it. So apparently, I used to many sockets, and therefore I got the exception. That explains why this happens only after a longer period of time. Basically, this sucks, because it means I'll need to implement HTTP keep alive to avoid using lots of sockets. To my other question (I forgot that one the first time ;) ): I also tried using the NonBlockingConnectionPool, but it doesn't seem to work very well... Above all it appears to be extremely very slow. Kind regards, Christiaan Willemsen Gregor Roth wrote: > Hi Christiaan, > > this could a bug. Please open a bug entry by adding your test code. > > Gregor > > > > > > 2007/10/31, Christiaan Willemsen <cwi...@te... > <mailto:cwi...@te...>>: > > Hi there, > > I have a client doing lots of request to a HTTP server, using about 20 > simultaneous connections. I use a while loop to create as many > connections as possible, and if I'm at max, I'll wait until another > connection was closed. This appears to work just fine for a while. > > But then, I start getting these exceptions: > > java.net.BindException: Address already in use: connect > at sun.nio.ch.Net.connect (Native Method) > at > sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:507) > at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:81) > at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java :65) > at > org.xsocket.stream.io.impl.IoProvider.openSocket(IoProvider.java:356) > at > org.xsocket.stream.io.impl.IoProvider.createClientIoHandler(IoProvider.java:219) > at org.xsocket.stream.Connection .<init>(Connection.java:162) > at > org.xsocket.stream.NonBlockingConnection.<init>(NonBlockingConnection.java:396) > at > org.xsocket.stream.NonBlockingConnection.<init>(NonBlockingConnection.java > :154) > > They occur in the constructor of connection NonBlockingConnection. This > happens with 1.2 and 1.2.1 > > Also, this started occurring after I implemented onConnect, instead of > sending the http POST data right after the construction of the > NonBlockingConnection. Mostly, the second time I try to create the > connection, it works, but this should not be happening I guess... > > So, what's the problem here? It looks like someone is trying to bind a > socket to a local tcp port that is already taken fore some reason. > > Kind regards, > > Christiaan Willemsen > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > <http://get.splunk.com/> > _______________________________________________ > xSocket-develop mailing list > xSo...@li... > <mailto:xSo...@li...> > https://lists.sourceforge.net/lists/listinfo/xsocket-develop > > |