Version 9

    I get IOException ping timeout, how do I fix it?

     

    Each connection pings the server once every PingPeriod. This is configured

    on the ConnectionFactory (e.g. jms/deploy/uil2-service.xml) and defaults to 60

    seconds.

    Its purpose is for the client to be able detect that the connection with the server

    has been broken.

     

    The mechanism is as follows:

    1. Client sends a ping to the server and rests for the PingPeriod

    2. After the PingPeriod has expired it checks that it got a Pong from the server

    3. Repeat from 1

     

    Reasons for Ping failure:

    1. The connection is broken, use Connection.setExceptionListener() to handle broken connections (usually by closing the old connection and reconnecting)

    2. Something horrible is going on, e.g. very long garbage collections or massive amounts of paging means the ping/pong doesn't get enough cpu to process in time i.e. either the client or server is failing big time to keep up with requests

    3. You send a large message that takes more than PingPeriod to send over the connection, the ping or pong waits behind the message for its turn to be processed UIL2 has a ChunkSize that simulates a Pong when that many bytes are sent over the network to avoid this problem.

    4. Some other problem like a deadlock see READTHISFIRST for how to debug this.

     

    I'm inside the application server, how do I install the exception listener?

     

    • You don't need to for an MDB, JBoss does it for you.

    • For anything else, you should be using the JMS resource adapter which also does it for you.

     

    I've installed an exception listener and closed the connection, but it is still giving the message

     

    Typical example from the forum, can you see the error? Don't cheat...

    protected void stopConnection() {
    try {
    if (queueConnection != null) {
    queueConnection.setExceptionListener(null);
    queueConnection.stop();
    queueConnection.close();
    }
    } catch (Exception ex) {
    logger.error("Error when try to stop Connection = " + ex.getMessage());
    } 
    

     

    Yes, the correct answer is that the

    connection.stop()

    throws a

    JMSException

     

    and

    connection.close()

    is not done.

     

    This will almost certainly happen since the connection is probably broken, as detected by the ping timeout.

     

    The

    stop()

    and any other tidyup is redundant anyway.

    connection.close()

    does ALL the work

    required to close sessions, producers, consumers, null the exception listener and the

    stop()

    itself.

     

    I've installed an exception listener, but it is still telling me to install an exception listener, how do I track down where the connection comes from?

     

    • Enable TRACE logging for jbossmq

    • The stacktrace where the connection was opened will be shown in the log, NOTE the connection id, e.g. Connection@29683960 in the following case:

    2007-03-20 11:46:30,250 TRACE [org.jboss.mq.Connection] Connection Initializing userName=null Connection@29683960[clientID=null rcvstate=STOPPED]
    2007-03-20 11:46:30,250 TRACE [org.jboss.mq.Connection] Getting the serverIL Connection@29683960[clientID=null rcvstate=STOPPED]
    2007-03-20 11:46:30,250 TRACE [org.jboss.mq.Connection] serverIL=org.jboss.mq.il.uil2.UILServerIL@a83a13 Connection@29683960[clientID=null rcvstate=STOPPED]
    2007-03-20 11:46:30,250 TRACE [org.jboss.mq.Connection] Authenticating user null Connection@29683960[clientID=null rcvstate=STOPPED]
    2007-03-20 11:46:30,252 TRACE [org.jboss.mq.il.uil2.UILServerIL] Begin connect loop, maxRetries=10, delay=0
    2007-03-20 11:46:30,252 TRACE [org.jboss.mq.il.uil2.UILServerIL] Connecting with addr=0:0:0:0:0:0:0:1, port=8093, localAddr=null, localPort=0, socketFactory=javax.net.
    DefaultSocketFactory@a89ce3, enableTcpNoDelay=true, bufferSize=2048, chunkSize=1000000
    2007-03-20 11:46:30,269 TRACE [org.jboss.mq.il.uil2.SocketManager] start called
    java.lang.Exception: Start stack trace
            at org.jboss.mq.il.uil2.SocketManager.start(SocketManager.java:112)
            at org.jboss.mq.il.uil2.UILServerIL.createConnection(UILServerIL.java:523)
            at org.jboss.mq.il.uil2.UILServerIL.getSocketMgr(UILServerIL.java:390)
            at org.jboss.mq.il.uil2.UILServerIL.authenticate(UILServerIL.java:277)
            at org.jboss.mq.Connection.authenticate(Connection.java:1065)
            at org.jboss.mq.Connection.<init>(Connection.java:252)
            at org.jboss.mq.Connection.<init>(Connection.java:323)
            at org.jboss.mq.SpyConnection.<init>(SpyConnection.java:116)
            at org.jboss.mq.SpyConnectionFactory.internalCreateConnection(SpyConnectionFactory.java:137)
            at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:108)
            at org.jboss.example.Client.main(Client.java:36)
    
    • This can be matched to the stacktrace on the asynch failure:

    2007-03-20 11:46:36,317 TRACE [org.jboss.mq.Connection] Notified of failure reason=Unexpected ping failure Connection@29683960[token=ConnectionToken:ID:7/324cfef34bc4f
    c7c4824d5ee727f1ae7 rcvstate=STARTED]
    org.jboss.mq.SpyJMSException: Cannot ping the JMS server; - nested throwable: (java.io.IOException: Client is not connected)
            at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:72)
            at org.jboss.mq.SpyJMSException.rethrowAsJMSException(SpyJMSException.java:57)
            at org.jboss.mq.Connection.pingServer(Connection.java:846)
            at org.jboss.mq.Connection$PingTask.run(Connection.java:1315)
            at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(ClockDaemon.java:364)
            at java.lang.Thread.run(Thread.java:595)
    Caused by: java.io.IOException: Client is not connected
            at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:264)
            at org.jboss.mq.il.uil2.SocketManager.sendReply(SocketManager.java:238)
            at org.jboss.mq.il.uil2.UILServerIL.ping(UILServerIL.java:345)
            at org.jboss.mq.Connection.pingServer(Connection.java:842)
            ... 3 more
    2007-03-20 11:46:36,317 WARN  [org.jboss.mq.Connection] Connection failure, use javax.jms.Connection.setExceptionListener() to handle this error and reconnect
    org.jboss.mq.SpyJMSException: Cannot ping the JMS server; - nested throwable: (java.io.IOException: Client is not connected)