AnsweredAssumed Answered

Issue while processing incoming subscription request

Question asked by Vaibhav Ranglani on Dec 4, 2015
Latest reply on Dec 4, 2015 by Vaibhav Ranglani

Hi All,

 

I am having some issues processing incoming presence subscription requests.

 

I am trying to create a chat app on android.

Here is my code.

 

Roster roster = Roster.getInstanceFor(connection);

roster.setSubscriptionMode(Roster.SubscriptionMode.manual);

roster.setRosterLoadedAtLogin(true);

/*if(!roster.isRosterLoadedAtLogin()) {*/
   try {

  roster.reload();

  } catch (SmackException.NotLoggedInException e) {

  e.printStackTrace();

  } catch (SmackException.NotConnectedException e) {

  e.printStackTrace();

  } catch (InterruptedException e) {

  e.printStackTrace();

  }

/*}*/
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);

roster.addRosterListener(new MyRosterListener());

/*StanzaFilter filter = new OrFilter(PresenceTypeFilter.SUBSCRIBE,PresenceTypeFilter.SUBSCRIBED, PresenceTypeFilter.UNSUBSCRIBE, PresenceTypeFilter.UNSUBSCRIBED);*/
StanzaFilter subscribeFilter = PresenceTypeFilter.SUBSCRIBE;

StanzaFilter subscribedFilter = PresenceTypeFilter.SUBSCRIBED;

PresenceSubscribePacketListener subscribeListener = new PresenceSubscribePacketListener(getApplicationContext(), connection);

PresenceSubscribedPacketListener subscribedListener = new PresenceSubscribedPacketListener(getApplicationContext(), connection);

connection.addSyncStanzaListener(subscribeListener,subscribeFilter);

connection.addSyncStanzaListener(subscribeListener,subscribedFilter);

 

This above code runs in a service.

 

But when I send an incoming presence packet with type="subscribe"

 

The app throws an error in the debugger.

 

The exception is as

E/Rosterīš• Exception reloading roster

    org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 100000ms (~100s). Waited for response using: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=mRY9a-11)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (ignoreResourcepart): +919876543214@localhost, FromMatchesFilter (full): localhost)).

            at org.jivesoftware.smack.AbstractXMPPConnection$7.run(AbstractXMPPConnection.java :1478)

            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)

            at java.util.concurrent.FutureTask.run(FutureTask.java:237)

            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:152)

            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu ledThreadPoolExecutor.java:265)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

            at java.lang.Thread.run(Thread.java:841)

Outcomes