powered by Jive Software

Connection Timed Out when trying to login to Google Talk

Hi All,

I am using Smack 2.2.0 (w/ JDK 1.5) and attempting to connect to GTalk services. I am working from behind a proxy server, and so I have set up the necessary proxy settings (as system properties). When I attempt to login, i get the following error stack:

XMPPError connecting to talk.google.com:5222.: (502)

– caused by: java.net.ConnectException: Connection timed out: connect

at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection. java:281)

at org.jivesoftware.smack.XMPPConnection.(GoogleTalkConnection.java:36)


“my code”


Has anyone else come across this issue?



Looking at the thread http://www.jivesoftware.org/community/thread.jspa?messageID=102946&#102946 , i guess, SMACK should make a check if a proxy has been defined in the system properties before opening the socket connection. If a proxy has been defined, then it should create a Socket object with the proxy information and then open the connection to the destination server.



  1. Modified the content a little bit.

Message was edited by: roguexz

I dont think it does. I set properly the proxy settings (with proxyHost, proxySet and proxyPort) and also tried a normal URLConnection to make sure it is working from behind my proxy server. However I get the same problem of connection timed out when I try a Google Talk connection from Smack. (Normal google talk client works through my proxy)

You can’‘t use Smack for google talk directly, since it doesn’‘t do the SRV resolve (which is absolutely required). You have to do that first and pass the host to Smack (don’‘t try to use Smack’‘s own SRV resolver, it’'s broken).

You might be interested in http://www.dnsjava.org/

I lost track now! How do you do that??


I would definitely like to know how to do this SRV thingy. Pardon me for my ingorance, any sample code would be great.



I’'ve used Smack directly for googletalk. Unless something has broken in the latest build :S

We’‘re not talking directly here… we’'re talking behind a normal proxy server. Are you behind a proxy or directly from a public IP?

I’'ve used Smack directly for googletalk. Unless

something has broken in the latest build :S

No, googletalk has changed, they now require SRV lookups to work properly.

In my code, I’'m now using ruli to resolve the SRV records, and googletalk works fine.

Good to know someone managed to get it to work.

Could you indicate what I have to do in my code to use the package you are saying and get Smack to use it?

Could you indicate what I have to do in my code to

use the package you are saying and get Smack to use


Well, I’‘m developing a client in Objective C, and so I’‘m using a C-based library. The code I’'m using is available at http://trac.adiumx.com/browser/branches/summer_of_code_2006/andreas_monitzer/Plu gins/Smack%20Service/SmackXMPPAccount.m?rev=16241#L318 (note that this forum breaks the URL, you have to join the lines). However, there are Java bindings available for that library, too.

Maybe you could indicate the steps I have to make? I am trying to use the package at www.dnsjava.org to get SRV records, but I have no idea what to do with them.

Do I still have to set the System properties to connect through the proxy? Does smack consider them? What do I have to do then, use the records that I get from the SRV DNS query and use them in the XMPP connection instead of talk.google.com.

An SRV record basically says for example “if you want to connect to the service xyz.com using the xmpp-protocol, you have to go to the server with the name jabber.xyz.com at port 5222”. The host you supply to Smack’'s ConnectionConfiguration is only resolved using A-records, which are the mapping server name -> IP.

What you have to do is to get the server name and port using the part of the user-supplied jabber id after the ‘’@’’. Then you can supply that server name and port to the connection configuration and use Smack with it. (of course, when the SRV-record cannot be obtained, you have to supply some sane replacement)

The service name is xmpp-client.tcp for c2s btw.