Sending incorrect presence type="probe" to gtalk, not even necessary

Hi there!

When starting a session with gtalk, the gateway send a to each of the contacts of the roster in gtalk.

I think this is not necessary. In the XMPP RFC, it even says that

presence type=“probe” should only be sent by a server, not by a user:

http://www.xmpp.org/rfcs/rfc3921.html#presence

2.2.1. Types of Presence

  1. probe – A request for an entity’s current presence; SHOULD be generated only by a server on behalf of a user.

I think that the code was doing it to try to avoid an error in the

smack library that prevented presences from the roster being received

( http://www.igniterealtime.org/community/thread/33278?tstart=0 )

After applying the fix noted in the thread above, it’s not necessary

to send this presence probes.

Anyway, if you are sure that you want to send this presence probes,

there’s a little bit of code to fix.

File XMPPSession.java, in the function syncUsers:

public void syncUsers() {
        for (RosterEntry entry : conn.getRoster().getEntries()) {
            getBuddyManager().storeBuddy(new XMPPBuddy(getBuddyManager(), entry.getUser(), entry.getName(), entry.getGroups(), entry));
            ProbePacket probe = new ProbePacket(getJID().toString(), entry.getUser());
            try {
                conn.sendPacket(probe);
            }
            catch (IllegalStateException e) {
                Log.debug("XMPP: Not connected while trying to send probe.");
            }
        }
...

The gateway sends within the smack connection to gtalk, a presence

type=“probe” to each of the contacts, from my user in the openfire

server.

Gtalk responds this way:

<presence type="probe" from="my-user@my-openfire-server" to="my-contanct1@gmail.com"/> <presence to="my-user@my-openfire-server" from="my-contact1@gmail.com" type="error">
  <error code="400" type="MODIFY">
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></bad-request>
    <text xml:lang="en" xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
      If set, the 'from' attribute must be set to the user's full JID.
    </text>
  </error>
</presence>

So, the presence packet is being sent with an incorrect JID from. It

should be the JID with wich the gtalk session is started with, e.g.,

"my-gtalk-user@gmail.com".

Since we don’t have access to the full JID the gtalk server has

assigned to us (it’s usually something like

"my-gtalk-user@gmail.com/random_string"), there’s no way of sending

the full JID.

So, if we are sure that we want to send these presence type=“probe”,

you should send them without from. SO you can apply this patch

diff --git a/src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java b/src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPP
index 6882705..3022af0 100644
--- a/src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java
+++ b/src/java/org/jivesoftware/openfire/gateway/protocols/xmpp/XMPPSession.java
@@ -514,7 +514,7 @@ public class XMPPSession extends TransportSession {
     public void syncUsers() {
         for (RosterEntry entry : conn.getRoster().getEntries()) {
             getBuddyManager().storeBuddy(new XMPPBuddy(getBuddyManager(), entry.getUser(), entry.getName(), entry.getGroups(), entry));
-            ProbePacket probe = new ProbePacket(getJID().toString(), entry.getUser());
+            ProbePacket probe = new ProbePacket(null, entry.getUser());
             try {
                 conn.sendPacket(probe);
             }

Thanks!!