powered by Jive Software

NoReponseException on connect(asmack 4.0.0)

ConnectionConfiguration config = new ConnectionConfiguration(

“192.168.8.158”, 5222);

XMPPConnection connection = new XMPPTCPConnection(config);

try {

connection.connect(); // Throw SmackException$NoReponseException here.

} catch (SmackException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

The openfire just use the default settings, and I can use Spark to connect the server.

Here is the logs.

06-16 03:20:31.187: W/PacketWriter(1576): Exception writing closing stream element

06-16 03:20:31.187: W/PacketWriter(1576): java.net.SocketException: Socket closed

06-16 03:20:31.187: W/PacketWriter(1576): at libcore.io.Posix.sendtoBytes(Native Method)

06-16 03:20:31.187: W/PacketWriter(1576): at libcore.io.Posix.sendto(Posix.java:155)

06-16 03:20:31.187: W/PacketWriter(1576): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)

06-16 03:20:31.187: W/PacketWriter(1576): at libcore.io.IoBridge.sendto(IoBridge.java:466)

06-16 03:20:31.187: W/PacketWriter(1576): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)

06-16 03:20:31.187: W/PacketWriter(1576): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)

06-16 03:20:31.187: W/PacketWriter(1576): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269 )

06-16 03:20:31.187: W/PacketWriter(1576): at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)

06-16 03:20:31.187: W/PacketWriter(1576): at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)

06-16 03:20:31.187: W/PacketWriter(1576): at java.io.BufferedWriter.flush(BufferedWriter.java:124)

06-16 03:20:31.187: W/PacketWriter(1576): at org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)

06-16 03:20:31.187: W/PacketWriter(1576): at org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)

06-16 03:20:31.187: W/PacketWriter(1576): at org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

06-16 03:20:50.299: W/System.err(1576): org.jivesoftware.smack.SmackException$NoResponseException

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.XMPPConnection.throwConnectionExceptionOrNoResponse(XMPP Connection.java:543)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwConnectionExceptionOrNoRespon se(XMPPTCPConnection.java:855)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.tcp.PacketReader.startup(PacketReader.java:114)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.j ava:477)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:435)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:799)

06-16 03:20:50.299: W/System.err(1576): at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:391)

06-16 03:20:50.303: W/System.err(1576): at com.example.newthingstest.ActivityChat$1.run(ActivityChat.java:55)

06-16 03:20:50.303: W/System.err(1576): at java.lang.Thread.run(Thread.java:841)

Exception writing closing stream element
For some reason Smack is already in the progress closing the stream. Check if there are any more exceptions or abnormalities in the log.

But these are all the infos, I’m just testing the openfire, so there’s only a few codes.

I add the code:

config.setSecurityMode(SecurityMode.disabled);

And then the app connected to the server.But why can’t I use SecurityMode.enabled?

1 Like

i dont how its related to this exception but i am having same issue and i set below line and all fixed

xMPPConfig.setSecurityMode(SecurityMode.disabled);

It seems your server not contains SLL certificate and this is the reason why its you have to disable that option until your server install some SLL certificate

It seems your server not contains SLL certificate and this is the reason why its you have to disable that option until your server install some SLL certificate
Every SSL/TLS enabled server comes with a certificate. The question is if the client deem this certificate as valid.