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.connect();
connection.login(“username”, “password”);

} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} `

But when i run this code this errors is showing …

org.jivesoftware.smack.SmackException$NoResponseException at org.jivesoftware.smack.XMPPConnection.throwConnectionExceptionOrNoResponse(XMPPConnection.java:548) at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwConnectionExceptionOrNoResponse(XMPPTCPConnection.java:867) at org.jivesoftware.smack.tcp.PacketReader.startup(PacketReader.java:113) at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.java:482) at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:440) at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:811) at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:396) at test.third.<init>(third.java:19) at test.third.main(third.java:34)

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