Re: Pooled connection closing sockets
Posted by: Andrew Ling
Date: December 09, 2016 04:30AM

I am not calling close on the PooledConnection. The socket is not getting closed immediately. If I reuse the PooledConnection quickly enough, the socket gets reused and stays open. It is only if the PooledConnection is left idle for something like 10 seconds that the socket gets closed. I can confirm this using netstat. This shows the same port numbers for an established socket so long as I keep using a connection. If I let the connection go idle, the socket with the port number pair noted goes into time-wait state and a new socket with a new port number connected to 3306 appears in the list.

If the socket was being closed and going into SOLINGER timeout immediately it couldn't be reused. So what you describe is not happening.

I have a list of PooledConnections. These get handed out to clients. The client calls PooledConnection.getConnection() to get the underlying Connection. The client then calls close on the Connection which using the ConnectionEventListener calls back to our connectionClosed event handler. This handler puts the PooledConnection back on the list without calling close.

The only time our code calls close on the PooledConnection is if we get an error event callback. If this happens we print a message and remove the connection from out pool. This is not happening. So something else in the background is closing the socket associated with a PooledConnection. I had assumed it was something in the mysql-connector and had hoped there was a way of changing the timeout before this happens.

Thanks for your help.

Options: ReplyQuote


Subject
Written By
Posted
Re: Pooled connection closing sockets
December 09, 2016 04:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.