Hi,
The pool is the version 1.4
The settings for the pool are:
pool = new GenericObjectPool(new PinCenterPoolFactory(), 10);
pool.setTestWhileIdle(true);
pool.setMaxIdle(5);
pool.setTimeBetweenEvictionRunsMillis(45000);
pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
The secuence of execution that I'm seeying is:
18:05:00 <DEBUG>[validateObject] Send message keepalive failed
Caused by: java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:124)
at
com.sodimac.irtm.pincenter.PinConnection.sendRequest(PinConnection.java:170)
... 6 more
18:05:03 <DEBUG>[destroyObject] Closing socket (client port=33792)
18:05:03 <DEBUG>[destroyObject] Closing socket (client port=33792)
...
...
18:24:58 <DEBUG>[getConnection-63262596] Objects in pool idle=1 active=-1
18:24:58 <DEBUG>[sendRequest-63262596] Sending message (client port:35525)
18:25:00 <DEBUG>[getConnection-730089636] Objects in pool idle=0 active=0
18:25:00 <DEBUG>[validateObject] Sending keepalive message
18:25:00 <DEBUG>[sendRequest-730089636] Enviando mensaje (client port:35525)
18:25:00 <DEBUG>[sendRequest-63262596] Recibiendo mensaje (client
port:35525)
18:25:01 <DEBUG>[sendRequest-730089636] Recibiendo mensaje (client
port:35525)
18:25:01 <DEBUG>[close-63262596] Returning socket to pool
18:25:01 <DEBUG>[close-730089636] Returning socket to pool
The main code of the pool is (I deleted some unimportants lines of code):
public class PinPoolFactory implements PoolableObjectFactory
{
private int numFails;
public PinPoolFactory() throws BadPropertiesException {
super();
}
public Object makeObject() throws UnknownHostException, IOException {
PinConnection con = new PinConnection();
return con;
}
public void destroyObject(Object o){
PinConnection con = (PinConnection)o;
try{
con.disconnect();
}catch(Exception e){
}
}
// Here we check that the connection is alive, first with the socket
state.
// If socket is connected we have to send a "keep alive" packet to
server.
public boolean validateObject(Object o){
PinConnection con = (PinConnection)o;
if(!con.isConnected()){
return false;
}
while(!con.keepAlive() && con.getFailedMessages()<numFails){
try{
con.disconnect();
con.connect();
}catch(Exception e){
}
};
if(con.getFailedMessages()!=0){
try{
con.disconnect();
}catch(Exception e){}
return false;
}
return true;
}
public void activateObject(Object o){
}
public void passivateObject(Object o){
}
}
Any Idea?
Germán
On Sun, Aug 3, 2008 at 10:20 AM, Phil Steitz <[EMAIL PROTECTED]> wrote:
> German Castro Donoso wrote:
>
>> Hello,
>>
>> I have a pool that contains tcp sockets, looking the log files i've
>> noticed
>> that some times when a socket fails (in the validateObject function) the
>> object is destroyed... but twice. After that, when the pool recive 2
>> simultaneus request for a socket, the pool give the same socket to two
>> diferent clients at the same time.
>>
>> Anybody had have a similar problem? it's a bug in my code or a bug in the
>> pool?
>>
>>
>>
> What version of pool are you running? Can you provide more info on
> configuration and what you are seeing in your code?
>
> Phil
>
>> Thanks for any help.
>> Germán
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>