We have a server application that is running in jboss, and we have started using smack as a means to notify when certain events happen within the application. However, we are seeing a problem that occurs with about 10% of the messages we send. That is that we see smack connect successfully to the jabber server, but we don’'t see any message sent, and then we see it disconnect.
Our server is Jabberd 1.4.2. We are running all messaging over SSL. We have been running Jabberd in debug mode so that we can see all events taking place in the server. Messages that are successful appear just as expected. We see our “smack” client establish an SSL session, become authenticated, then we see the message sent to the expected recipient, and then we see the closing of the SSL session. However, on the occasions when it fails, we see the “smack” client establish an SSL, session, become authenticated, but we do not see the message being sent, and then we see the closing of the SSL session.
Our debug log for our jboss application traces the calls we are making to smack and we can see a one to one correlation with the messages being sent in jboss with the connection of smack with the server. But in the case of a failed message, we still see in our jboss log that the message was sent, but at the jabber server side a message never gets sent, we only see the session created and then disconnected.
We have provided our code below…
Has anyone else seen this type of behavior, or know how we might better determine what is going wrong in our process.
public static boolean sendIM( Integer nAccountId, Vector to , String strMsg )
{
boolean bRetVal = false ;
SSLXMPPConnection IMconnection = null ;
Chat chat = null ;
String strRecipientName = null; if(nAccountId.intValue()==1) {
try {
GlobalUtils.log( CLASS_NAME, GlobalUtils.kLOG_INFO, "Sending Jabber message..."); // Connect if we are not connected already
IMconnection = ConnToJabberServer(nAccountId);
// Send to each recipient
Iterator iter = to.iterator();
while( iter.hasNext() ) {
strRecipientName = ( String ) iter.next();
if ( IMconnection != null ) {
if ( IMconnection.isConnected() ) {
chat = IMconnection.createChat( strRecipientName + "." + nAccountId.toString() + "@" + kJabberServerName) ;
if (chat != null) {
chat.sendMessage(".\n- Hi " + strRecipientName + " -\n" + strMsg );
GlobalUtils.log( CLASS_NAME, GlobalUtils.kLOG_INFO, "Sent message to: " + strRecipientName + "." + nAccountId.toString() + "@" + kJabberServerName);
}
else {
GlobalUtils.log( CLASS_NAME, GlobalUtils.kLOG_INFO, "Failed to create jabber chat object...");
}
bRetVal = true ;
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
finally {
if ( IMconnection != null )
if ( IMconnection.isConnected() )
IMconnection.close() ;
}
}
return( bRetVal );
}
Message was edited by: KrashTestDummy