Error in connect to xmpp(openfire) server using java

I am new in xmpp. For a whole day i am stuck in connecting my xmpp server(openfire version 3.9.3) by java. I am using smack(version 4.0.7) library. Here is simple code…

`ConnectionConfiguration config =new ConnectionConfiguration(“servername”,5223);
XMPPTCPConnection connection = new XMPPTCPConnection(config);
// Connect to the server
try {
connection.login(“username”, “password”);

} catch (IOException e) {
} catch (XMPPException e) {
} catch (SmackException e) {
} `

But when i run this code this errors is showing …

org.jivesoftware.smack.SmackException$NoResponseException at org.jivesoftware.smack.XMPPConnection.throwConnectionExceptionOrNoResponse( at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwConnectionExceptionOrNoResponse( at org.jivesoftware.smack.tcp.PacketReader.startup( at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection( at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration( at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal( at org.jivesoftware.smack.XMPPConnection.connect( at test.third.<init>( at test.third.main(

There may be a silly mistake and easy solution, i googled but but somehow i am not getting the right solution.please help me. I am eagerly waiting for your reply, guys Thanks in advance

I would check your “servername” to make sure it matches to that of your OpenFire server, if not already.

try using port 5222, and try using IP address in place of servername