Kambiz Kambiz - 3 months ago 17
Apache Configuration Question

No persistant connection in TCP connection poll implemented by Apache Common Pool

How can I use Apache common pool to pool TCP connections and reuse the connection?

To implement a TCP connection pool, I am trying to use Apache common pool(1.6), I used the object pool that is posted in https://javaarchitectforum.com/tag/apache-common-object-pool-example/ to implement it.

I do expect to see persisted TCP connection upon initiating connection to another server and reuse it for other subsequent connection requests.

The issue is, I can not see any persistent connection to the server(netstat -an). By borrowing object, new connection is established and when return the object, socket is disconnected.No pooling!

Am I using correct approach to create TCP pool?

Answer Source

Issue is resolved.

Upon returning object, the DataOutputStream was also closed. By keeping the DataOutputStream open and also by keeping alive clientSocket upon makeObject()[clientSocket.setKeepAlive(true)], the issue is resolved.