Smack Api often could not disconnect from MSN. User is still appears online although i invoke disconnect method

I experience a quite disturbing behavior using smack to build a XMPP Client for connecting to MSN and Gtalk. I can set up the connection successfully and I can chat with my application.

But in MSN case (Not Gtalk), when I try to disconnect from MSN service. Sometimes I’m getting this exception :

java.lang.IllegalStateException: Not connected to server.at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:445)

In catch block of this exception, I’m setting up new connection. and then send disconnect again. In that case , I can disconnect from MSN network. But sometimes couple of seconds user is appear online again to its buddies.

When i run this comment in Solaris, i can see a lot of leak connections :

netstat -an|grep 5222

tcp 0 0 195.175.239.22:54845 65.54.49.40:5222 ESTABLISHED

tcp 0 186 195.175.239.22:60223 65.54.52.62:5222 ESTABLISHED

tcp 0 0 195.175.239.22:36584 65.55.71.33:5222 ESTABLISHED

tcp 0 0 195.175.239.22:45535 65.54.48.138:5222 ESTABLISHED

tcp 0 0 195.175.239.22:55885 65.54.50.83:5222 ESTABLISHED

tcp 0 0 195.175.239.22:60628 65.55.71.94:5222 ESTABLISHED

Please help me with these issue. This issue is very critical for our application.

Best Regards,

Alper Ozdamar