Plugin with XMPP connection for file transfer error

I have been working on a plugin that can send and receive file transfers. To do so, I have the plugin create a registered connection with the Openfire server that handles all of the file transfer interaction. The connection is made just fine when I upload the plugin, however, if I restart the server I get the following error and the client connection is not established:

XMPPError connecting to remote-server-error(502) XMPPError connecting to
– caused by: Connection refused: connect
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection. java:830)
at org.jivesoftware.smack.XMPPConnection.connect(
at services.model.connection.ModelServiceConnection.establishConnection(ModelServi at line 140 is:

134 ConnectionConfiguration connConfig;
135 connConfig = new ConnectionConfiguration(“”, 5222);
136 connection = new XMPPConnection(connConfig);


138 try
139 {
140 connection.connect();
141 }

Any thoughts on why when the server is restarted it would deny the plugin from establishing an XMPPConnection with the server but the initial upload runs fine?

It appears that the connection for the contact can not be established when the plugin is initialized. I moved the connection call to occur the first time a message comes through and it works fine.