powered by Jive Software

Gtalk gateway - contact presence problem

hi,

i am developing an gtalk gateway for the openfire server by using the smack library. i am using smack lite for debugging.

i can get registered the service and sign in with my gmail account, but after signing in, i can not get the online presences of my contacts

as i see in the debugger, i send the packets of the presences by one by like the following as my listener presence function fired

<presence to="admin@xxx.net" from=“xxx\40gmail.com@gtalk.xxx.net”/>

but these packes doesn’'t show up in the smack debugger.

i see that, for example yahoo gateway, send 3 presence for just one contact, one is unavailable and the others are available. should i send 3 presence for just one contact, too?

but these packets doesn’'t show up in the smack debugger.

any ideas?

Hrm. I don’‘t want to deter you or anything, but I happen to be working on that for the IM Gateway plugin as well. That said, I don’‘t really know what to tell you re: Smack and I might suggest asking the Smack Support forum. (I’'m actually having issues getting it going myself, but for other reasons) Is your gateway implemented as a piece of the IM Gateway plugin, or completely standalone?

as a piece.

after making some tests, i have found out that, if i do not register any other transports, gtalk transport is working succesfully. but if i register msn or yahoo, than gtalk transport begins to behave suspicious. it sometimes send the presence packets, sometimes not.

so i have ran a port explorer to see what is going on. and then i sent a packet in the debugger it says

gtalk: Sending packet:

but in the port explorer, this packet does not exist, so i think the problem is with the openfire 3.3.0.

any ideas how to debug that and find out the exact problem?

I… don’‘t know! That’‘s rather bizarre! I can’‘t think of any reason why they wouldn’'t be getting along. Of course, the Smack library does not play asynchronously in some cases (like logging in) so it might be hanging everything else briefly or something like that.

jadestorm, as far as i know you are the developer of the IM gateway plugin, did you have this kind of problem while developing the other transports? or if you are working gtalk gateway, how is it going? at which state are you?

ok, i have found the solution, all the login processes of the transports should run in threads.

I am indeed. =) The only other transport I had similar problems with is the Yahoo one. It also needs to be run in threads for the login process. I’‘m not very far with my GTalk gateway. I made an XMPPTransport basically that is used for GTalk and for “any old XMPP server”. I didn’‘t get very far because for some reason I kept running into problems getting authed with the target server. =/ All of my code is in SVN though. I ran into the same problem and set up the login process to run via threads. I’‘m not entirely pleased that it isn’‘t asynchronous inherently, but what are ya gonna do. =) If you are interested in perhaps merging your work into mine and it being an official part of the plugin, I’‘d be all for it. (of course, unfortunately, I have to get you to sign some sort of agreement with Jive Software before I can accept anything. it’‘s just an agreement that you won’‘t come back later and say “actually I wanted to charge for this”) Don’‘t know if you are interested. Basically since I couldn’‘t get logged in, I didn’‘t get very far at all. I still don’‘t know what’'s going on with the logins though.

thanks jadestorm for your offer, but it is not a possible situation. But please be sure that, i can help you anything about the gateways.

Ok =) Well I’'ll continue on with mine as well.

hi again jadestorm,

there are still problems with the first contact presence packets, now i made msn, yahoo and gtalk login processes run in seperate threads and still i can not send the gtalk contacts presences in the first time just after signing in.

if you want to see what is going on, try to send different packets from different threads at the same time, you will see that you won’'t be able to send all the packets to the client succesfully.

you know anything about how openfire sends/queue the packets or should i work on the openfire sources?

Still openfire doesn’'t send the all packets.

Naw, I’‘m afraid I do not know. I haven’'t looked at the actual code that handles that. (I typically ask Gato since he knows his code backwards and forwards =) )

Now that I think about it though, I recall that in the past I had tried to make -everything- run inside separate threads and that failed miserably. Perhaps this is why?

If i register only gtalk gateway, it gives no error, and i can always get the presence packets after the login. But if i add yahoo or another registration, then gtalk sends the packet succesfully again but openfire doesn’'t transport the packets to the connected client.

/**

  • Sends a packet through the component manager as the component.
  • @param packet Packet to be sent.

*/

public void sendPacket(Packet packet) {

System.out.println(getType().toString()*": Sending packet: "*packet.toXML());

try {

this.componentManager.sendPacket(this, packet);

}

catch (Exception e) {

System.out.println(“Error!”);

Log.error("Failed to deliver packet: " + packet.toString());

}

}

the above code is from the BaseTransport class, my presence packets comes to here as i debug, i see

gtalk: Sending packet:

in the logs. But this.componentManager.sendPacket(this, packet); line doesn’'t do its function.

Now i am pretty sure it is something about openfire.

hehe, I knew my part of it, just not what’‘s going on in openfire land itself. that said . . . ug. =( yeah i’‘m actually seeing a -lot- of weird bugs going on beyond my scope. for example, i keep getting some sort of compression errors. like the MSN transport will try to send something and then i’‘ll get a traceback that’‘s deep within mina amongst some sort of zlib support. =/ going to ping gato when i have a moment/ when he’'s free.

jadestorm, i have a question, how can we simulate a gtalk user presence. In the login function, i have commented everything and wrote some line to simulate an user presence but still can not send the users presence.

setLoginStatus(TransportLoginStatus.LOGGED_IN);

Presence p = new Presence();

p.setTo(getJID());

p.setFrom(getTransport().getJID());

getTransport().sendPacket§;

List();

legacyusers.add(new TransportBuddy("test@gmail.com", “nick”, null));

try {

getTransport().syncLegacyRoster(getJID(), legacyusers);

} catch (UserNotFoundException ex) {

ex.printStackTrace();

}

Presence userPresence = new Presence();

userPresence.setTo(getJID());

userPresence.setFrom(getTransport().convertIDToJID("test@gmail.com"));

getTransport().sendPacket(userPresence);

getRegistration().setLastLogin(new Date());

jadestorm, there is really a BIG problem with the IM GATEWAY.

I can send anycommand to the client from the BaseTransport using this.sendPacket() but not from the instances that extends the BaseTransport class like YahooTransport. Something goes wrong with that. I am working on that.

i am like answering my own questions :stuck_out_tongue:

after a full research, i have found that smack api is running synchronously and blocking the whole process. As msn api doesn’'t run like that, there is no problem with that. So i am making rebuilding the smack api to run asynchronously with the help of the threads. I plan to share the latest build with you.

Is it running synchronously in more than just the login process? (i knew about the login process itself) I had planned at one point on wrapping the entire session instance in a thread. That might not be a bad idea. Maybe. I hate to say it but I wonder if there are any other “definitely asynchronous” java implementations out there. =)

if you run yahoo with msn, or run gtalk with msn, no problem occurs. the reason is, msn is running asynchronously. but if you try to run yahoo with gtalk you, than you notice that some packets do not arrive. Here is the explanation:

as you know both yahoo and gtalk signs in very fast, compared to msn. Because of that reason, when you trigger both of them at the same time, this means when you register the two gateways and sign in, yahoo begins signing in process and blocks everything. meanwhile, gtalk is connected and try to send packets, but unfortunately since the yahoo blocked the gateway, the packets can not be sent.

i have re-builded smack api to run asynchronously and now i have no problem with gtalk signing in process, my client gets every packet succesfully.