java - Unable to connect to Openfire server (using smack api) -


i trying run code using smack 4.1.0

 thread d= new thread(new runnable() {              @override             public void run() {                 smackconfiguration.setdefaultpacketreplytimeout(10000);                 xmpptcpconnectionconfiguration config = xmpptcpconnectionconfiguration.builder()                         .setusernameandpassword("harsh", "pass")                         .setservicename("192.168.0.200")                         .sethost("192.168.0.200")                         .setport(5223).setsecuritymode(connectionconfiguration.securitymode.ifpossible)                         .build();                  abstractxmppconnection conn2 = new xmpptcpconnection(config);                 try {                     conn2.connect();                      conn2.login();                      presence presence = new presence(presence.type.unavailable);                     presence.setstatus("gone fishing");                     // send packet (assume have xmppconnection instance called "con").                     conn2.sendstanza(presence);                  } catch (smackexception | ioexception | xmppexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                     log.d("tag", e.tostring());                 }                  chatmanager chatmanager = chatmanager.getinstancefor(conn2);                   chat newchat = chatmanager.createchat("harsh@192.168.0.200");                  try {                     newchat.sendmessage("howdy!");                 }                 catch (smackexception.notconnectedexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 }                }         });              d.start();       } 

this gives me error :

05-15 14:59:35.350    4417-4439/com.example.smacktester w/system.err﹕ org.jivesoftware.smack.smackexception$noresponseexception: no response received within reply timeout. timeout 10000ms (~10s). used filter: no filter used or filter 'null'. 05-15 14:59:35.351    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.synchronizationpoint.checkforresponse(synchronizationpoint.java:192) 05-15 14:59:35.352    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.synchronizationpoint.checkifsuccessorwait(synchronizationpoint.java:114) 05-15 14:59:35.352    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.synchronizationpoint.checkifsuccessorwaitorthrow(synchronizationpoint.java:97) 05-15 14:59:35.352    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.tcp.xmpptcpconnection.connectinternal(xmpptcpconnection.java:837) 05-15 14:59:35.352    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.abstractxmppconnection.connect(abstractxmppconnection.java:360) 05-15 14:59:35.354    4417-4439/com.example.smacktester w/system.err﹕ @ com.example.smacktester.mainactivity$1.run(mainactivity.java:50) 05-15 14:59:35.354    4417-4439/com.example.smacktester w/system.err﹕ @ java.lang.thread.run(thread.java:818) 05-15 14:59:35.355    4417-4439/com.example.smacktester d/tag﹕ org.jivesoftware.smack.smackexception$noresponseexception: no response received within reply timeout. timeout 10000ms (~10s). used filter: no filter used or filter 'null'. 05-15 14:59:35.365    4417-4444/com.example.smacktester w/abstractxmppconnection﹕ connection closed error     org.xmlpull.v1.xmlpullparserexception: unexpected token (position:text ��p@1:8 in java.io.bufferedreader@16ea33d4)             @ org.kxml2.io.kxmlparser.next(kxmlparser.java:432)             @ org.kxml2.io.kxmlparser.next(kxmlparser.java:313)             @ org.jivesoftware.smack.tcp.xmpptcpconnection$packetreader.parsepackets(xmpptcpconnection.java:1151)             @ org.jivesoftware.smack.tcp.xmpptcpconnection$packetreader.access$200(xmpptcpconnection.java:937)             @ org.jivesoftware.smack.tcp.xmpptcpconnection$packetreader$1.run(xmpptcpconnection.java:952)             @ java.lang.thread.run(thread.java:818) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ org.jivesoftware.smack.smackexception$notconnectedexception: client not, or no longer, connected 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.tcp.xmpptcpconnection$packetwriter.thrownotconnectedexceptionifdoneandresumptionnotpossible(xmpptcpconnection.java:1226) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.tcp.xmpptcpconnection.thrownotconnectedexceptionifappropriate(xmpptcpconnection.java:336) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.abstractxmppconnection.sendstanza(abstractxmppconnection.java:609) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.chat.chatmanager.sendmessage(chatmanager.java:365) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.chat.chat.sendmessage(chat.java:114) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ org.jivesoftware.smack.chat.chat.sendmessage(chat.java:98) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ com.example.smacktester.mainactivity$1.run(mainactivity.java:71) 05-15 14:59:35.377    4417-4439/com.example.smacktester w/system.err﹕ @ java.lang.thread.run(thread.java:818) 05-15 14:59:56.335    4417-4417/com.example.smacktester i/timeline﹕ timeline: activity_idle id: android.os.binderproxy@2763795b time:38739229 05-15 15:00:19.772   4417-4427/com.example.smacktester w/art﹕ suspending threads took: 10.531ms 05-15 15:02:44.503    4417-4427/com.example.smacktester w/art﹕ suspending threads took: 7.832ms 

and, after enabling debugging in local openfire server, message:

2015.05.15 14:50:03 index.jsp - failed fetch rss feed: javax.net.ssl.sslhandshakeexception: java.security.cert.certificateexception: root certificate not trusted of [vanity2.jiveon.com] 

where going wrong ?

as per discussion user problem .setport(5223) in xmpptcpconnectionconfiguration .port 5223 default client ssl port in openfire,

you can change port setting in  openfire 3.10 admin panel  

server >> server settings >> client connections

error

org.jivesoftware.smack.smackexception$noresponseexception: no response received within reply timeout. timeout 10000ms (~10s).

means trying connecting ssl enabled port [5223] out doing sasl negotiation. means need store ssl certificate provided xmpp server[opnefire] in application[some in internal/external memory] ,and use same certificate further communication xmpp server on ssl port.

for ssl authentication can user truststore

for more information on xmpp sasl negotiation refer link


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -