blueiceprj / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

XMPP Ping Not Supported #47

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What are you doing to produce the error?
1. Sending XMPP Server pings to aSmack client
2.
3.

What is the expected output?
This is the XMPP Standards page defining pings.
Should return a "pong".
http://xmpp.org/extensions/xep-0199.html

What do you see instead? (Please attach a debug enabled logcat)
This is server side logs, aSmack doesn't show logs for pings not implemented.

*** THIS MEANS CLIENT IS ONLINE, BUT THE FEATURE IS NOT IMPLEMENTED***
log: level: 0, area: 131072, 
<iq from='MY_CLIENT@DOMAIN/RESOURCE' to='MYBOT@DOMAIN/RESOURCE' 
id=uid:4d46c3a0:68e3df63' type='error'>
      <error code='501' type='CANCEL'>
            <feature-not-implemented xmlns='urn:ietf:params:xml:n:xmpp-stanzas'/>
      </error>
</iq>

*** THIS MEANS CLIENT IS OFFLINE OR DOESN'T EXIST ***
log: level: 0, area: 131072, 
<iq from='MY_CLIENT@DOMAIN/RESOURCE' to='MYBOT@DOMAIN/RESOURCE' type='error' 
xml:lang='en' id='uid:4d46c3a0:43e44ccf'>
      <ping xmlns='urn:xmpp:ping'/>
      <error code='503' type='cancel'>
           <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
      </error>
</iq>

What version of aSmack / Android / Device do you use?
aSmack issue 15
Android 2.2.1
Motorola DROID

What server do you use? Is there a public server to reproduce the problem?
We use ejabberd. This is not a public server. Its easy to reproduce, just send 
pings from server to client.

Original issue reported on code.google.com by cwyson...@gmail.com on 31 Jan 2011 at 2:22

GoogleCodeExporter commented 8 years ago
I noticed the same thing.

Is there someone who still develops or asmack? seems dead.

Original comment by fusion...@gmail.com on 18 Mar 2011 at 9:42

GoogleCodeExporter commented 8 years ago
Without really going into the library,  a quick fix can be done with something 
like: 
1) create class Ping extends IQ implements IQProvider
2) add to ProviderManager -> pm.addIQProvider("ping", "urn:xmpp:ping", new 
Ping());
3) create class PingPacketListener implements PacketListener which answers to a 
Ping IQ :)

Hope it helps.
-s

Original comment by fusion...@gmail.com on 19 Mar 2011 at 10:03

GoogleCodeExporter commented 8 years ago
I just implement a sample code based on the above guideline : 
http://www.softhinker.com/in-the-news/respondtoxmpppingtokeepidleclientalive

Original comment by qind...@softhinker.com on 5 Mar 2012 at 3:37

GoogleCodeExporter commented 8 years ago
You will find a version which contains a fix for this issue at the new home of 
aSmack: https://github.com/flowdalic/asmack

Original comment by fschm...@gmail.com on 20 Feb 2013 at 4:40

GoogleCodeExporter commented 8 years ago
okay

asmack does not support ping replies, So I have a very little hack. I was 
facing this issue, What I did is that, I just made a listener 

PacketListener myListener = new PacketListener().....

then registered it with

connection.addPacketListener(myListener, new PacketTypeFilter(Packet.class));

so in processPacket method of my listener I just checked the packet instance

if(packet instanceof Ping) {
   Ping ping = new Ping();
   ping.setTo(packet.getFrom());
   ping.setType(Type.RESULT);
   connection.sendPacket(ping);
}

thats it..

in openfire documentation, it is mentioned that, if you client responses with 
any result, it is considered to be alive...

Original comment by moonza...@gmail.com on 14 Nov 2013 at 7:16

GoogleCodeExporter commented 8 years ago
aSmack does support XMPP ping. Your code is not needed and btw incomplete 
because it doesn't register ping with the service discovery manager.

Original comment by fschm...@gmail.com on 16 Nov 2013 at 10:15