powered by Jive Software

Authentication error when connecting to gtalk using smack-3.0.4_beta1

Hi all!

I encountered this exception when connecting to gtalk server , I’'m using smack-3.0.4_beta1

No response from the server.:

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:58)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 232)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:341)

at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1287)

at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:163)

these are the codes I’'m using to connect to gtalk server

XMPPConnection xmppconn = new XMPPConnection(“gmail.com”);

//the code below produces the same result

//XMPPConnection xmppconn = new XMPPConnection(“talk.google.com”,5222,“gmail.com”);


xmppconn.login(userName, password,resource);

Is it means smack-3.0.4_beta1 hasn’'t resolved the bug http://www.igniterealtime.org/issues/browse/SMACK-224?

Is there anybody encountered the same problem as mine?

The bug is resolved. Are you using GTalk in the US or some where else? Use the following working example as a starting point.

import java.io.IOException;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils; public class SendTest {
        // Notice the username is NOT smack.test@gmail.com
    private static String username = "smack.test";
    private static String password = "ignite";
        public static class MessageParrot implements PacketListener {
        private XMPPConnection xmppConnection;
                public MessageParrot(XMPPConnection conn) {
            xmppConnection = conn;
                public void processPacket(Packet packet) {
            Message message = (Message)packet;
            if(message.getBody() != null) {
                String fromName = StringUtils.parseBareAddress(message.getFrom());
                System.out.println("Message from " + fromName + "\n" + message.getBody() + "\n");
                Message reply = new Message();
                reply.setBody("I am a Java bot. You said: " + message.getBody());
            public static void main( String[] args ) {
                System.out.println("Starting IM client");
                // gtalk requires this or your messages bounce back as errors
        ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
        XMPPConnection connection = new XMPPConnection(connConfig);
                try {
            System.out.println("Connected to " + connection.getHost());
        } catch (XMPPException ex) {
            System.out.println("Failed to connect to " + connection.getHost());
        try {
            connection.login(username, password);
            System.out.println("Logged in as " + connection.getUser());
                        Presence presence = new Presence(Presence.Type.available);
                    } catch (XMPPException ex) {
            // XMPPConnection only remember the username if login is succesful
            // so we can''t use connection.getUser() unless we log in correctly
            System.out.println("Failed to log in as " + username);
                PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
        connection.addPacketListener(new MessageParrot(connection), filter);
                if(args.length > 0) {
            // google bounces back the default message types, you must use chat
            Message msg = new Message(args[0], Message.Type.chat);
                System.out.println("Press enter to disconnect\n");
                try {
        } catch (IOException ex) {

Am using the following code to connect to GTalk.

When I try running the code, it gives the following error"[java.net|http://java.net.co/].ConnectException:

Connection timed out: connect". Please let me where is it going wrong.

I am behind a proxy, but am able to connect successfully when I use the

GTalk client messenger.



Error Starts

Starting IM client

XMPPError connecting to talk.google.com:5222.:

remote-server-error(502) XMPPError connecting to talk.google.com:5222.

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

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

at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)

at com.pramati.web122.imsupport.SendTest.main(SendTest.java:50)

Nested Exception:

[java.net|http://java.net.co/].ConnectException: Connection timed out: connect at [java.net|http://java.net.plainsocketimpl.so/].PlainSocketImpl.socketConnect(Native Method)


at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)

at com.pramati.web122.imsupport.SendTest.main(SendTest.java:50)

Error Ends