Not logged in. · Lost password · Register
Forum: agsXMPP RSS
My bad code blew up.
Page:  1  2  next
Avatar
ayyrk #1
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
Subject: Unhandled exception
I passed in a malformed JID ( jsmith.gmail.com instead of jsmith@gmail.com ) into the agsxmpp sdk and it generated ( I believe ) and unhandled exception against talk.google.com. Maybe there is a try/catch missing in my application but I don't know where it should go.  (the error was something a 403 forbidden)

The exception is generated in the agsxmpp class: XGoogleTokenMechanism

The line is: HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

The method is: private void OnGetClientAuthResponse(IAsyncResult result)

I put a try/catch in OnGetClientAuthResponse and called base.XmppClientConnection.Close(); in the handler.

By the way, I am just experimenting with agsxmpp so if I posted this in the wrong place or it is an obvious programmer error please disregard.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

this is not a malformed Jid. Its a correct Jid which includes only the server part.
Are you running the latest SVN code? I think agsXMPP should raise an auth error then because the X-Token authentication fails with a wrong Jid.

Alex
Avatar
ayyrk #3
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
I am running SVN code from about two weeks ago.

I said it was a malformed JID because I meant to type jsmith@gmail.com into my login screen but I typed jsmith.gmail.com by accident.

That caused the exception to be thrown by request.EndGetResponse(result);

So far that is all I know - I will be very happy to run tests or send you any more information you think I can gather.
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sorry i forgot to checkin a new file.
Please checkout XGoogleTokenMechanism from SVN again.

Thanks
Alex
Avatar
ayyrk #5
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
Hi,  I am using the latest SVN code and got this exception. (This happend one time in about fifty trials)


NullReferenceException

at agsXMPP.sasl.XGoogleToken.XGoogleTokenMechanism.OnGetClientAuthResponse()
at System.Net.LazyAsyncResult.InvokeCallback()
at System.Net.HttpWebRequestasyncGetResponse()
at WorkItem.doWork()
at System.Threading.Timer.ring()
Avatar
ayyrk #6
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
A little more information on the OnGetClientAuthResponse() null pointer exception:  It just happened again when I plugged the WM6 device into a laptop to sync and charge.

I am not sure if it is related but at that point the device was connected to talk.google.com over GPRS. When plugged in Connection Manager detects the active sync connection and hang up GPRS.
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you try to debug this?
I'm sorry, but we have no device here where we can switch connections from GPRS to Active Sync.

Alex
Avatar
rajeevc #8
User title: Rajeev
Member since Sep 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
I am getting a 403 forbidden response in XGoogleTokenMechanism.OnGetClientAuthResponse which is preventing authentication from succeeding. I've double checked the credentials several times and they are ok. It is worth noting, I only see this when running from a pocketpc2003 device. I can connect fine in the miniclient running on my desktop computer. The last message I get over xml (on the pocketpc) is something like the following and then auth fails after that:

<stream:features xmlns:stream=\"http://etherx.jabber.org/streams\"><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>

Is this simply not going to work on pocketpc unless ssl/tls is supported through this library?

This is the code I used:

System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); // did this to avoid a server trust exception

            //xmpp.UseSSL = false;  // cannot set variable here on pocketpc
            xmpp.Port = 5222;
            //xmpp.UseStartTLS = false;  // cannot set variable here on pocketpc
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Server = "gmail.com";
            xmpp.Username = "myuser@gmail.com";

            xmpp.Password = "mypw";
            xmpp.Resource = "test";
            try
            {
                xmpp.Open();
            }
            catch (Exception ex)
            {
                this.textBoxDebug.Text = ex.Message;
            }


thanks,
Rajeev
Avatar
Alex #9
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The pocket PC code and the desktop code authenticate with different SASL mechanisms because there is no TLS available on teh compact framework yet.
The username in your code is wrong. You provide a full jid here instead of the username only. Remove the server part (@gmail.com).

Alex
Avatar
rajeevc #10
User title: Rajeev
Member since Sep 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
That worked. Thanks.
Avatar
rajeevc #11
User title: Rajeev
Member since Sep 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #5
I got this exact same null pointer exception. After debugging this, it looks like we.Response can be null once in awhile, and when that happens, it causes a null pointer exception on line 143 of XGoogleTokenMechanism.cs (svn rev. 21):

                if (((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.Forbidden)
....

This should probably be handled more gracefully (i.e. first check for null we.Response and handle appropriately from there)?

thanks,
Rajeev
Avatar
Jabberer #12
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
thanks we check the code again and will fix this.
Software Developer
AG-Software
Avatar
Alex #13
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
ok i took a look at the code again.
If WebException is null then there is probably another exception than a WebException.
Can you please try to change the code to:

  1. catch (WebException we)
  2. {
  3.     if (((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.Forbidden)
  4.     {
  5.         base.XmppClientConnection.FireOnAuthError(null);
  6.         base.XmppClientConnection.Close();
  7.     }
  8. }
  9. catch (Exception ex)
  10. {
  11.     // try to debug this and post the stacktrace
  12.     base.XmppClientConnection.FireOnAuthError(null);
  13.     base.XmppClientConnection.Close();
  14. }

and post a stacktrace of the exception?
I never has an exception here while debugging, so I'm sorry that I can't cause this error.

Alex
Avatar
rajeevc #14
User title: Rajeev
Member since Sep 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
Actually what happens, is we get a WebException, but the if we.Response returns null causing a null reference exception at ((((HttpWebResponse)we.Response).StatusCode):

if (((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.Forbidden)
....

So catching the generic exception, while useful, is not the problem in this particular case.

Rajeev
Avatar
Alex #15
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
ok understand now.

then this should fix it:

  1. catch (WebException we)
  2. {   
  3.     base.XmppClientConnection.FireOnAuthError(null);
  4.     base.XmppClientConnection.Close()
  5. }

i think we don't need to to evaluate to response. because if there is a webexception the authentication will fails anyway.

Alex
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:
Page:  1  2  next
Forum: agsXMPP RSS