Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
naveed #1
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Subject: Cannot connect to Gmail Server
Hi,

I am very new to agsXMPP. I am trying to connect Gmail server with following configuration to send a message on login to my self but I am unable to :(.

Any help / pointers would be very helpful. The two users are real and are in each others friends list.

As this is just a sample, I have used console application.

using System;
using System.Collections.Generic;
using System.Text;
using agsXMPP.protocol.client;
using agsXMPP.protocol;
using agsXMPP;


namespace AgsxmppSample
{
    class Program
    {
      
      
       
        static void Main(string[] args)
        {
            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = "gmail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
            xmpp.Username = "epichatty@googlemail.com";
            xmpp.Password = "*********";
            xmpp.AutoResolveConnectServer = false;
            xmpp.Open();
            xmpp.OnLogin += delegate(object o)
            {
                xmpp.Send(new Message
                    ("naveed.ahmad@gmail.com", MessageType.chat, "Hello, how are you?, auto message from epichatty"));
               
            };
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(xmpp.XmppConnectionState);
                Console.WriteLine(xmpp.Authenticated);
                //For XmppConnectionState I get connecting and for Authenticated i get False
               
                 System.Threading.Thread.Sleep(100000);
            }
            Console.ReadLine();
            xmpp.Close();
        
        }
    }
}
This post was edited on 2009-11-04, 11:37 by naveed.
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
the Username and Server properties are wrong.
  • The Username is the domain part only, in your case epichatty.
  • Server is googlemail.com.
Avatar
naveed #3
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Thanks for the reply, I have modifed the code but still no luck.

Is there anything else I could do?

 XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = "googlemail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
            xmpp.Username = "epichatty";
            xmpp.Password = "*******";
            xmpp.AutoResolveConnectServer = false;
            xmpp.Open();
            xmpp.OnLogin += delegate(object o)
            {
                xmpp.Send(new Message
                    ("naveed.ahmad@gmail.com", MessageType.chat, "Hello, how are you?, auto message from epichatty"));
               
            };
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(xmpp.XmppConnectionState);
                Console.WriteLine(xmpp.Authenticated);

                System.Threading.Thread.Sleep(10000);
            }
            Console.ReadLine();
            xmpp.Close();
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
then please subscribe to the OnReadXml and OnWriteXml handlers and post your log.
Avatar
naveed #5
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
In the main code, I added these handlers

xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);

and implemented these as


    static void xmpp_OnError(object sender, Exception ex)
        {
            Console.WriteLine("Error!!!!" + ex.Message.ToString());
        }

        static void xmpp_OnWriteXml(object sender, string xml)
        {
            Console.WriteLine("SEND XML: " + xml);
        }

        static void xmpp_OnReadXml(object sender, string xml)
        {
            Console.WriteLine("REC XML: " + xml);
        }

The response i get is

Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False

SEND XML: </stream:stream>
Press any key to continue . . .
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
please put all handlers in the code before you open the connection.
And please try the examples which ship with the SDK, do they work for you?
Avatar
naveed #7
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
I have tried the Gtalk example that is shipped, but that is not working :(

I have amenede as you said, here is the full code again

using System;
using System.Collections.Generic;
using System.Text;
using agsXMPP.protocol.client;
using agsXMPP.protocol;
using agsXMPP;


namespace AgsxmppSample
{
    class Program
    {
      
      
       
        static void Main(string[] args)
        {
            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = "googlemail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
            xmpp.Username = "epichatty";
            xmpp.Password = "*********";
            xmpp.AutoResolveConnectServer = false;
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnLogin += delegate(object o)
            {
                xmpp.Send(new Message
                    ("naveed.ahmad@gmail.com", MessageType.chat, "Hello, how are you?, auto message from epichatty"));

            };
         
            xmpp.Open();
          
          
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(xmpp.XmppConnectionState);
                Console.WriteLine(xmpp.Authenticated);

                System.Threading.Thread.Sleep(1000);
            }
           // Console.ReadLine();
            xmpp.Close();
        
        }

      

        static void xmpp_OnError(object sender, Exception ex)
        {
            Console.WriteLine("Error!!!!" + ex.Message.ToString());
        }

        static void xmpp_OnWriteXml(object sender, string xml)
        {
            Console.WriteLine("SEND XML: " + xml);
        }

        static void xmpp_OnReadXml(object sender, string xml)
        {
            Console.WriteLine("REC XML: " + xml);
        }
    }
}


Response is the same

Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
Connecting
False
SEND XML: </stream:stream>
Press any key to continue . . .

Is there any other debugging tool that I can use or how long on the average I have to wait before login ?
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by naveed:
I have tried the Gtalk example that is shipped, but that is not working :(

If this and the MiniClient don't work then there is something wrong on your machine or your network.
Can you try another XMPP account than GTalk? e.g. on the jabber.org server.
The connect/login is normally very fast.
Avatar
naveed #9
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
May be something in my office firewall policies that is not allowing me to connect. I wil try it from home in the evening.

Thanks for the help so far.
Avatar
naveed #10
Member since Nov 2009 · 6 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
port 5222 was blocked in our firewall, now its all working fine.

Connecting
False
SEND XML: <stream:stream to='googlemail.com' xmlns='jabber:client' xmlns:stream=
'http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
REC XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="go
oglemail.com" version="1.0" id="D5C1435675A5733A" >
REC XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><start
tls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required /></starttls><mechanisms x
mlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></m
echanisms></stream:features>
SEND XML: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
REC XML: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
SEND XML: <stream:stream to='googlemail.com' xmlns='jabber:client' xmlns:stream=
'http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
REC XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="go
oglemail.com" version="1.0" id="4C1EA5D77377E917" >
REC XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mecha
nisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mech
anism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
SEND XML: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXXXXXXXX</auth>
REC XML: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
SEND XML: <stream:stream to='googlemail.com' xmlns='jabber:client' xmlns:stream=
'http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
REC XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="go
oglemail.com" version="1.0" id="957400E34E9E209B" >
REC XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><bind
xmlns="urn:ietf:params:xml:ns:xmpp-bind" /><session xmlns="urn:ietf:params:xml:n
s:xmpp-session" /></stream:features>
SEND XML: <iq id="agsXMPP_1" type="set" to="googlemail.com"><bind xmlns="urn:iet
f:params:xml:ns:xmpp-bind"><resource>agsXMPP</resource></bind></iq>
REC XML: <iq xmlns="jabber:client" from="googlemail.com" type="result" id="agsXM
PP_1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>epichatty@googlemail.c
om/agsXMPP76DD3973</jid></bind></iq>
SEND XML: <iq id="agsXMPP_2" type="set" to="googlemail.com"><session xmlns="urn:
ietf:params:xml:ns:xmpp-session" /></iq>
REC XML: <iq xmlns="jabber:client" from="googlemail.com" type="result" id="agsXM
PP_2" />
SEND XML: <message to="naveed.ahmad@gmail.com" type="chat"><body>Hello, how are
you?, auto message from epichatty</body></message>
SEND XML: <iq id="agsXMPP_3" type="get" to="googlemail.com"><query xmlns="jabber
:iq:agents" /></iq>
SEND XML: <iq id="agsXMPP_4" type="get"><query xmlns="jabber:iq:roster" /></iq>
REC XML: <iq xmlns="jabber:client" from="googlemail.com" to="epichatty@googlemai
l.com/agsXMPP76DD3973" type="error" id="agsXMPP_3"><query xmlns="jabber:iq:agent
s" /><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:pa
rams:xml:ns:xmpp-stanzas" /></error></iq>
REC XML: <iq xmlns="jabber:client" to="epichatty@googlemail.com/agsXMPP76DD3973"
 type="result" id="agsXMPP_4"><query xmlns="jabber:iq:roster"><item jid="naveed.
ahmad@gmail.com" subscription="both" /><item ask="subscribe" jid="twitter@twitte
r.com" subscription="none" /></query></iq>
SEND XML: <presence><status /><priority>5</priority></presence>
REC XML: <message xmlns="jabber:client" from="naveed.ahmad@gmail.com" to="epicha
tty@googlemail.com" iconset="classic"><body>I am good</body><met:google-mail-sig
nature xmlns:met="google:metadata">d9954a8b98065e1f</met:google-mail-signature><
x xmlns="jabber:x:delay" stamp="20091105T11:57:22" /><time xmlns="google:timesta
mp" ms="1257422242364" /></message>
REC XML: <presence xmlns="jabber:client" from="naveed.ahmad@gmail.com/gmail.B8A3
046C" to="epichatty@googlemail.com/agsXMPP76DD3973"><priority>24</priority><caps
:c xmlns:caps="http://jabber.org/protocol/caps" ext="pmuc-v1 sms-v1 vavinvite-v1
" ver="1.1" node="http://mail.google.com/xmpp/client/caps" /><status /><x xmlns=
"vcard-temp:x:update"><photo>ee32fd1b736e751e4e6472608756ac1ce0941d8b</photo></x
></presence>
SessionStarted
True
SessionStarted
True
REC XML: <message xmlns="jabber:client" from="naveed.ahmad@gmail.com/gmail.B8A30
46C" to="epichatty@googlemail.com/agsXMPP76DD3973" type="chat" iconset="classic"
 id="A4CE03FE91090E1F_1"><body>how you doing</body><met:google-mail-signature xm
lns:met="google:metadata">b19bb754a766b59b</met:google-mail-signature><cha:activ
e xmlns:cha="http://jabber.org/protocol/chatstates" /><nos:x xmlns:nos="google:n
osave" value="disabled" /><arc:record xmlns:arc="http://jabber.org/protocol/arch
ive" otr="false" /></message>
SessionStarted
True
SessionStarted
True
This post was edited 2 times, last on 2009-11-05, 14:00 by Alex.
Edit reason: removed plain passwords from debug XML
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS