roy mathew
roy mathew

Reputation: 7800

How to know message sending has failed in asmack

I am trying to send a message using asmack and I am getting an error like this in log cat:

07-23 13:44:45.759: D/SMACK(20581): RCV (0): <message from='[email protected]' to='[email protected]/false' type='error' id='7DOua-233'><body>dgvvvcvcvhcbfbfvgchcbgbhgbhvnhbnvbvbhgbbbbhvbcnvbvbvbvvvcbvcbv hvvvbcvbbhnhjbnnvjbbnnnvnhbnbbbnnn</body><error code='500' type='wait'><resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Your contact offline message queue is full. The message has been discarded.</text></error></message>

This is the code:

if(mConnection!=null)
                {
                    Message msg = new Message(params[0], Message.Type.chat);
                    msg.setBody(params[1]);  
                    try
                    {
                        System.out.println("sending..");
                        mConnection.sendPacket(msg);
                        System.out.println("sent!"+msg.getBody());
                        System.out.println("sent!"+msg.getTo());
                        flag=true;
                    }
                    catch(Exception e)
                    {
                        System.out.println("Exception:"+e);
                    }
                }

How can I catch the above log cat error in my own try catch block? In the current case it is returning true even if message sending has failed. How can I know whether the message sending has failed due to the error like above.

Upvotes: 3

Views: 602

Answers (2)

Pankaj Kumar
Pankaj Kumar

Reputation: 67

In your xmpp server go to offline messages settings and set a very high limit for storing offline messages such as 1024 KB and also check always store messages even if the maximum size has been reached.

Hope this works!

Upvotes: -1

Rohit P Soman
Rohit P Soman

Reputation: 1161

Add a packet listner and check the type of packet received. If its an error your message is not delivered.

Upvotes: 2

Related Questions