title: Offline message not retrive from smack api 4.1.6 from xmpp MongooseIM server
body: <p>I am facing the issue to retrieve offline message in android apps using smack api from XMPP Mongoose server. As per the code flow Try to retrive offline message when user become login in xmpp mongoose server before sending available presence to mongoose server. </p>
  
  <p>Tried with two different way to retrieve offline message still not able to find working solution for the same. Both method which i tried those all things are explain below with detail.</p>
  
  <p>Below Api we are using for the xmpp connection and all other extension :</p>
  
  <p>// Smack (XMPP Client Library) </p>
  
  <p>compile 'org.igniterealtime.smack:smack-android:4.1.6'</p>
  
  <p> compile 'org.igniterealtime.smack:smack-tcp:4.1.6'</p>
  
  <p>compile 'org.igniterealtime.smack:smack-im:4.1.6' </p>
  
  <p>compile 'org.igniterealtime.smack:smack-android-extensions:4.1.6'</p>
  
  <p><strong><em>Tried retrive offline message Using offlineMessageManager</em></strong></p>
  
  <p>Below is code which I tried to retrieve offline message after login and before send available presence to server</p>
  
  <p>try { </p>
  
  <p>Boolean isFelxibleRetrievalSupport = offlineMessageManager.supportsFlexibleRetrieval(); </p>
  
  <p>Iterator i = (Iterator) offlineMessageManager.getMessages(); </p>
  
  <p>while (i.hasNext())</p>
  
  <p>{  Message msg = i.next();  System.out.println("Got text [" + msg.getBody() + "] from [" + msg.getFrom() + "]");  </p>
  
  <p>} catch (XMPPException e)</p>
  
  <p>{  System.out.println("Error Offline Message.");  e.printStackTrace();  }</p>
  
  <p>catch (SmackException.NotConnectedException e)</p>
  
  <p>{  System.out.println("Error Offline Message. No connection");  e.printStackTrace();  }</p>
  
  <p>catch (SmackException.NoResponseException e)</p>
  
  <p>{  System.out.println("Error Offline Message. No Reponse");  e.printStackTrace();  }</p>
  
  <p><strong>Issue case 1:</strong></p>
  
  <p>Below is exception detail which generate when above code execute</p>
  
  <p>I got Exception when execute below line of code. </p>
  
  <p>Iterator i = (Iterator) offlineMessageManager.getMessages(); </p>
  
  <p>Below is exception description which Generate when above line execute</p>
  
  <p>org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: service-unavailable - cancel</p>
  
  <p><strong>Issue Case 2:</strong></p>
  
  <p>If checking is Flexible offline message supported from android code using smack  from xmmp mongoose server so i got false value. Below is code which i used for testing.</p>
  
  <p>Boolean isFelxibleRetrievalSupport = offlineMessageManager.supportsFlexibleRetrieval();</p>
  
  <p><strong>Issue Case 3:</strong></p>
  
  <p>When I try to retrieve supported features using below method using smack code like below.</p>
  
  <p>ServiceDiscoveryManager manager = ServiceDiscoveryManager</p>
  
  <p>.getInstanceFor(connection);</p>
  
  <p>List AllFetures = manager.getFeatures();</p>
  
  <p>Below is features list which i retrived:</p>
  
  <p><a href="http://jabber.org/protocol/bytestreams" rel="nofollow">http://jabber.org/protocol/bytestreams</a>,</p>
  
  <p>jabber:iq:privacy, urn:xmpp:ping,</p>
  
  <p><a href="http://jabber.org/protocol/commands" rel="nofollow">http://jabber.org/protocol/commands</a>,</p>
  
  <p>jabber:iq:version,</p>
  
  <p>jabber:iq:last,</p>
  
  <p><a href="http://jabber.org/protocol/xdata-validate" rel="nofollow">http://jabber.org/protocol/xdata-validate</a>,</p>
  
  <p><a href="http://jabber.org/protocol/xhtml-im" rel="nofollow">http://jabber.org/protocol/xhtml-im</a>,</p>
  
  <p>vcard-temp,</p>
  
  <p><a href="http://jabber.org/protocol/chatstates" rel="nofollow">http://jabber.org/protocol/chatstates</a>,</p>
  
  <p>urn:xmpp:receipts, urn:xmpp:time,</p>
  
  <p><a href="http://jabber.org/protocol/xdata-layout" rel="nofollow">http://jabber.org/protocol/xdata-layout</a>,</p>
  
  <p><a href="http://jabber.org/protocol/muc" rel="nofollow">http://jabber.org/protocol/muc</a>,</p>
  
  <p><a href="http://jabber.org/protocol/disco#items" rel="nofollow">http://jabber.org/protocol/disco#items</a>,</p>
  
  <p><a href="http://jabber.org/protocol/disco#info" rel="nofollow">http://jabber.org/protocol/disco#info</a>,</p>
  
  <p><a href="http://jabber.org/protocol/caps" rel="nofollow">http://jabber.org/protocol/caps</a>,</p>
  
  <p>jabber:x:data</p>
  
  <p><strong>Tried to retreive offline message Using package listener from XMPP MongooseIM</strong></p>
  
  <p>below is code which i tried using package listener from smack api 4.1.6.</p>
  
  <p>private static final StanzaFilter MESSAGE_PACKET_FILTER= new OrFilter(StanzaTypeFilter.MESSAGE);</p>
  
  <p>configuration = XMPPTCPConnectionConfiguration.builder()</p>
  
  <pre><code>            .setServiceName(SERVICE_NAME)
  
              .setHost(KDevelopmentXMPPServer)
  
              .setPort(PORT)
  
              .setSendPresence(false)
  
              .build();
  </code></pre>
  
  <p>// Create Connection object of xmpp connection with configured detail</p>
  
  <p>connection = new XMPPTCPConnection(configuration);</p>
  
  <p>connection.addAsyncStanzaListener(new StanzaListener() {</p>
  
  <pre><code>            @Override
  
              public void processPacket(Stanza packet) throws SmackException.NotConnectedException {
  
  
                  Log.d("CheckPacket", "OfflineMEssage");
  
  
                  Message message = (Message) packet;
  
                  if (message != null) {
  
                      if (message.getBody() != null) {
  
  
  
                          Log.i("XMPPClient", "Got text [" + message.getBody()
  
                                  + "] from [" + message.getFrom() + "]");
  
  
  
                      }
  
                  }
  
  
  
              }
  
          }, MESSAGE_PACKET_FILTER);
  </code></pre>
  
  <p>connection.login(user, password);</p>
  
  <p>Thanks In Advance, Please anybody help me for best working solution for my critical issue.</p>