java - Smack 4.1 No Response within reply timeout -


i using following code in android app:

thread d= new thread(new runnable() {              @override             public void run() {                 smackconfiguration.setdefaultpacketreplytimeout(10000);                 xmpptcpconnectionconfiguration config = xmpptcpconnectionconfiguration.builder()                           .setusernameandpassword("admin", "password")                           .setservicename("192.168.0.200")                           .sethost("192.168.0.200")                           .setport(5223).setsecuritymode(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 (notconnectedexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 }                }         });             d.start(); 

this returning error:

05-14 18:07:48.030: d/tag(19470): org.jivesoftware.smack.smackexception$noresponseexception: no response received within reply timeout. timeout 10000ms (~10s). used filter: no filter used or filter 'null'.

i have set local server @ 192.168.0.200. tell me problem ?

i using these libraries:

enter image description here

i have connected local openfire server , logged in without ssl. here code

public class newclientactivity extends activity {     edittext etusername, etpassword;     button bsubmit;     abstractxmppconnection mconnection;     connectionlistener connectionlistener = new connectionlistener() {         @override         public void connected(xmppconnection xmppconnection) {             log.d("xmpp", "connected");             try {                 saslauthentication.registersaslmechanism(new saslmechanism() {                     @override                     protected void authenticateinternal(callbackhandler callbackhandler) throws smackexception {                      }                      @override                     protected byte[] getauthenticationtext() throws smackexception {                         byte[] authcid = tobytes('\u0000' + this.authenticationid);                         byte[] passw = tobytes('\u0000' + this.password);                         return byteutils.concact(authcid, passw);                     }                      @override                     public string getname() {                         return "plain";                     }                      @override                     public int getpriority() {                         return 410;                     }                      @override                     public void checkifsuccessfulorthrow() throws smackexception {                      }                      @override                     protected saslmechanism newinstance() {                         return this;                     }                 });                 mconnection.login();             } catch (xmppexception e) {                 runonuithread(new runnable() {                     @override                     public void run() {                         toast.maketext(newclientactivity.this, "incorrect username or password", toast.length_long).show();                     }                 });                 e.printstacktrace();             } catch (smackexception e) {                 e.printstacktrace();             } catch (ioexception e) {                 e.printstacktrace();             }         }          @override         public void authenticated(xmppconnection xmppconnection, boolean b) {             log.d("xmpp", "authenticated");             runonuithread(new runnable() {                 @override                 public void run() {                     toast.maketext(newclientactivity.this,"logged in successfully...",toast.length_long ).show();                 }             });         }          @override         public void connectionclosed() {             log.d("xmpp", "connection closed");         }          @override         public void connectionclosedonerror(exception e) {             log.d("xmpp", "cononection closed on error");         }          @override         public void reconnectionsuccessful() {             log.d("xmpp", "reconnection successful");         }          @override         public void reconnectingin(int i) {             log.d("xmpp", "reconnecting in " + i);         }          @override         public void reconnectionfailed(exception e) {             log.d("xmpp", "reconnection failed");         }     };      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_new_client);         findviews();     }      private void findviews() {         etusername = (edittext) findviewbyid(r.id.etusername);         etpassword = (edittext) findviewbyid(r.id.etpassword);         bsubmit = (button) findviewbyid(r.id.bsubmit);         bsubmit.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 string[] params = new string[]{etusername.gettext().tostring(), etpassword.gettext().tostring()};                 new connect().executeonexecutor(asynctask.thread_pool_executor, params);             }         });     }      class connect extends asynctask<string, void, void> {         @override         protected void doinbackground(string... params) {              xmpptcpconnectionconfiguration config = null;             xmpptcpconnectionconfiguration.builder builder = xmpptcpconnectionconfiguration.builder();             builder.setservicename("192.168.1.60").sethost("192.168.1.60")                     .setdebuggerenabled(true)                     .setport(5222)                     .setusernameandpassword(params[0], params[1])                     .setsecuritymode(connectionconfiguration.securitymode.disabled)                     .setcompressionenabled(false);             config = builder.build();              mconnection = new xmpptcpconnection(config);             try {                 //mconnection.setpacketreplytimeout(10000);                 mconnection.addconnectionlistener(connectionlistener);                 mconnection.connect();             } catch (smackexception e) {                 e.printstacktrace();             } catch (ioexception e) {                 e.printstacktrace();             } catch (xmppexception e) {                 e.printstacktrace();             }             return null;         }     } } 

Comments

Popular posts from this blog

Email notification in google apps script -

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

javascript - IE11 incompatibility with jQuery's 'readonly'? -