Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
tjabber #1
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: Can connect to gtalk with AutoResolveConnectServer=true but fails when false
When I set directly what I think are the correct parameters to gtalk I am disconnected:

        mClientCon.Server = "gmail.com";
        mClientCon.Username = "user";
        mClientCon.Password = "password";
        mClientCon.Resource = "resource";
        mClientCon.Priority = 10;
        mClientCon.Port = 5222;
        mClientCon.UseSSL = true;
        mClientCon.AutoResolveConnectServer = false;
        mClientCon.ConnectServer = "talk.google.com";
        mClientCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
        mClientCon.UseStartTLS = true;

OnSaslStart
SEND:<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXX</auth>
OnXmppConnectionStateChanged: Disconnected


But when I use AutoResolveConnectServer resolve it works fine:

        mClientCon.Server = "gmail.com";
        mClientCon.Username = "user";
        mClientCon.Password = "password";
        mClientCon.Resource = "email";
        mClientCon.Priority = 10;
        mClientCon.AutoResolveConnectServer = true;
        mClientCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;

OnSaslStart
SEND:<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXX</auth>
RECV:<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
OnXmppConnectionStateChanged: Authenticated


Now I'm happy it works, but I'm really curious why it doesn't work in the first case? What is getting set with AutoResolveConnectServer  that isn't being set by hand?

thanks
This post was edited 2 times, last on 2012-12-14, 13:19 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you please post the complete xml log for AutoResolveConnectServer=true

Thanks
Alexander Gnauck
AG-Software
Avatar
tjabber #3
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Certainly,

OnInitialized
LogOn: server=gmail.com uri=user password=password
OnLoggingOn
OnXmppConnectionStateChanged: Connecting
LogOn: myfulljid=user@gmail.com/client bare=user@gmail.com user=user server=gmail.com resource=client
OnXmppConnectionStateChanged: Connected
SEND:<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
IPV4
RECV:<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="62B09131169672D5" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
RECV:<stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
OnXmppConnectionStateChanged: Securing
SEND:<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
RECV:<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
Cipher: Rc4 strength 128
Hash: Md5 strength 128
Key exchange: RsaKeyX strength 1024
Protocol: Tls
Is authenticated: True as server? False
IsSigned: True
Is Encrypted: True
Certificate revocation list checked: True
Remote cert was issued to CN=gmail.com, O=Google Inc., L=Mountain View, S=California, C=US and is valid from 4/11/2007 10:17:38 AM until 4/10/2012 10:17:38 AM.
Can read: True, write True
Can timeout: True
SEND:<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
OnXmppConnectionStateChanged: Authenticating
The thread 0x1110 has exited with code 0 (0x0).
RECV:<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="1DD2EC235B43D41A" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
RECV:<stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
OnSaslStart
SEND:<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXX</auth>
RECV:<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
OnXmppConnectionStateChanged: Authenticated
SEND:<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
RECV:<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="0C063129847C3F67" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
RECV:<stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>
OnXmppConnectionStateChanged: Binding
SEND:<iq id="agsXMPP_1" type="set" to="gmail.com"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>client</resource></bind></iq>
RECV:<iq from="gmail.com" id="agsXMPP_1" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>user@gmail.com/clientCDB3C575</jid></bind></iq>
OnXmppConnectionStateChanged: Binded
OnXmppConnectionStateChanged: StartSession
SEND:<iq id="agsXMPP_2" type="set" to="gmail.com"><session xmlns="urn:ietf:params:xml:ns:xmpp-session" /></iq>
OnIq iq=<iq xmlns="jabber:client" from="gmail.com" type="result" id="agsXMPP_1"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>user@gmail.com/clientCDB3C575</jid></bind></iq>
RECV:
RECV:<iq from="gmail.com" type="result" id="agsXMPP_2"/>
OnXmppConnectionStateChanged: SessionStarted
OnLogin
SEND:<presence><status /><priority>10</priority><c xmlns="http://jabber.org/protocol/caps" ext="cp ep-notify html" ver="2jmj7l5rSw0yVb/vlWAYkK/YBwk=" /></presence>
SEND:<iq id="agsXMPP_3" type="get"><query xmlns="jabber:iq:privacy"><list name="client-privacy-list" /></query></iq>
OnLoggedOn
SEND:<iq id="agsXMPP_4" type="get" to="gmail.com"><query xmlns="http://jabber.org/protocol/disco#items" /></iq>
SEND:<iq id="agsXMPP_5" type="get" to="gmail.com"><query xmlns="jabber:iq:agents" /></iq>
SEND:<iq id="agsXMPP_6" type="get"><query xmlns="jabber:iq:roster" /></iq>
OnIq iq=<iq xmlns="jabber:client" from="gmail.com" type="result" id="agsXMPP_2" />
RECV:<iq id="agsXMPP_3" type="error" to="user@gmail.com/clientCDB3C575"><query xmlns="jabber:iq:privacy"><list name="client-privacy-list"/></query><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
OnIq iq=<iq xmlns="jabber:client" to="user@gmail.com/clientCDB3C575" type="error" id="agsXMPP_3"><query xmlns="jabber:iq:privacy"><list name="client-privacy-list" /></query><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
Received privacy element.
Error in privacy element error=NotImplemented message=

thanks
This post was edited on 2012-12-14, 13:20 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
it connects fine, there is no error in this log.
Is it possible that you app gets an unhandled exception and disconnects?
Alexander Gnauck
AG-Software
Avatar
tjabber #5
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Oh, you want the failure case. Here it is:


            mClientCon.Username = mConnectionInfo.Uri;
            mClientCon.Server = mConnectionInfo.Server;
            mClientCon.Password = mConnectionInfo.Password;
            mClientCon.Resource = "client";
            mClientCon.Priority = 10;
            mClientCon.Port = 5222;
            mClientCon.AutoResolveConnectServer = false;
            mClientCon.AutoAgents = false;
            mClientCon.RegisterAccount = false;
            mClientCon.UseCompression = false;
            mClientCon.UseStartTLS = true;
            mClientCon.UseSSL = true;

OnInitialized
LogOn: server=gmail.com uri=user password=password
OnLoggingOn
IPV4
OnXmppConnectionStateChanged: Connecting
LogOn: myfulljid=user@gmail.com/client bare=user@gmail.com user=user server=gmail.com resource=client
IMServerError: Error=NETWORK_ERROR SessionId=-1 Message=Socket error: msg=Attempt to connect timed out exception= Description=

thanks
Avatar
Alex #6
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you can either use Tls or Ssl, but not both like you do here:

  1. mClientCon.UseStartTLS = true;
  2. mClientCon.UseSSL = true;

if you look in the source you will see that these options toggle each other.

and if you use Ssl which is not recommended you can't use Port 5222

Alex
Alexander Gnauck
AG-Software
This post was edited on 2008-03-11, 23:30 by Alex.
Avatar
tjabber #7
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Hm, I thought that was the proper config for gtalk, sorry.

Unfortunately it still fails, but it fails more interestingly:

            mClientCon.Username = mConnectionInfo.Uri;
            mClientCon.Server = mConnectionInfo.Server;
            mClientCon.Password = mConnectionInfo.Password;
            mClientCon.Resource = "client";
            mClientCon.Priority = 10;
            mClientCon.Port = 5222;
            mClientCon.AutoResolveConnectServer = false;
            mClientCon.AutoAgents = false;
            mClientCon.RegisterAccount = false;
            mClientCon.UseCompression = false;
            mClientCon.UseStartTLS = true;
            mClientCon.UseSSL = false;
            mClientCon.ConnectServer = "talk.google.com";
            mClientCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;

OnXmppConnectionStateChanged: Connecting
LogOn: myfulljid=user@gmail.com/client bare=user@gmail.com user=user server=gmail.com resource=client
OnXmppConnectionStateChanged: Connected
SEND:<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
RECV:<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="F6CED78C0C6B781E" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
RECV:<stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
OnSaslStart
SEND:<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">XXX</auth>
OnXmppConnectionStateChanged: Disconnected
IMServerError: Error=NETWORK_ERROR SessionId=-1 Message=Server was disconnected. Description=
OnError: err=NETWORK_ERROR
OnClose
Shutdown
OnLoggingOff
SEND:</stream:stream>
OnLoggedOff
OnShuttingDown
OnShutdown
This post was edited on 2012-12-14, 13:20 by Alex.
Avatar
Alex #8
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
in your log only the Google XToken sasl mechanism is advertised. This is normally only the case when you are on a plain socket. So something sets UseStartTls = false before the connection is established.
Alexander Gnauck
AG-Software
Avatar
Alex #9
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
wrote a small example with the code you posted:

  1. mClientCon.Username = "username";
  2. mClientCon.Server = "gmail.com";
  3. mClientCon.Password = "secret";
  4. mClientCon.Resource = "client";
  5. mClientCon.Priority = 10;
  6. mClientCon.Port = 5222;
  7. mClientCon.AutoResolveConnectServer = false;
  8. mClientCon.AutoAgents = false;
  9. mClientCon.RegisterAccount = false;
  10. mClientCon.UseCompression = false;
  11. mClientCon.UseStartTLS = true;
  12. mClientCon.UseSSL = false;
  13. mClientCon.ConnectServer = "talk.google.com";
  14. mClientCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;

works fine for me without problems.
Alexander Gnauck
AG-Software
Avatar
tjabber #10
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #8
When I do a find all references I don't see it being set to false:

C:\agsxmpp\sasl\SaslHandler.cs - (100, 46) : if (m_XmppClient.UseStartTLS == false && m_XmppClient.UseSSL == false
C:\agsxmpp\XmppClientConnection.cs - (307, 21) : public bool UseStartTLS
C:\JabberIMLib\IMServerAdapter.cs - (372, 24) : mClientCon.UseStartTLS = true;

And I don't see UseSSL being set to true anywhere.
Avatar
Jabberer #11
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Alex's example works fine with my Gmail test account too.

Which version of agsxmpp are you using?
Can you write a small test case which causes this problem?
Software Developer
AG-Software
Avatar
tjabber #12
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
The changelog says version 0.95. The test case is pretty much the code as displayed. I have event handlers and such but I don't think that would impact anything. With my luck lately it doesn't surprise me that the same code works for someone else :-)
Avatar
Alex #13
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I tested your code with 1.0
Alexander Gnauck
AG-Software
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 SDK Support RSS