Subject: WM 6.0: Getting an exception in crypto.dll
I am writing a test XMPP client for wm6.0 to talk to Gmail. I downloaded the latest SDK and copied the two dlls (agsxmpp.dll and crypto.dll) from the <AGSXMPPSDK>\agsxmpp\bin\CF2\Release directory to the project and did the usual VS stuff. When I run the client in emulator, I get an exception that I have no idea what I should/can do.
Thanks for your help.
Output leading upto the exception
IPV4
Waiting...
ClientSocket_OnSend
<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
ClientSocket_OnReceive
<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="9E0F7E9D6A02CC5E" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
The thread 0x565f12ea has exited with code 0 (0x0).
ClientSocket_OnSend
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
ClientSocket_OnReceive
<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>
ClientSocket_OnSend
<presence><status /><priority>5</priority></presence>
ClientSocket_OnSend
<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
ClientSocket_OnReceive
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechani
ClientSocket_OnSend
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
ClientSocket_OnReceive
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
OnError
A first chance exception of type 'System.IO.EndOfStreamException' occurred in crypto.dll
at Org.BouncyCastle.Crypto.Tls.TlsUtilities.ReadUint8()
at Org.BouncyCastle.Crypto.Tls.RecordStream.ReadData()
at Org.BouncyCastle.Crypto.Tls.TlsProtocolHandler.Connect()
at agsXMPP.net.ClientSocket.StartTls()
at agsXMPP.XmppClientConnection.StreamParserOnStreamElement()
at agsXMPP.Xml.StreamParser.DoRaiseOnStreamElement()
at agsXMPP.Xml.StreamParser.EndTag()
at agsXMPP.Xml.StreamParser.Push()
at agsXMPP.XmppConnection.SocketOnReceive()
at agsXMPP.net.BaseSocket.FireOnReceive()
at agsXMPP.net.ClientSocket.EndReceive()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
---
Here is the full code..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using agsXMPP;
using agsXMPP.protocol;
using agsXMPP.protocol.iq;
using agsXMPP.protocol.iq.disco;
using agsXMPP.protocol.iq.roster;
using agsXMPP.protocol.iq.version;
using agsXMPP.protocol.client;
using agsXMPP.protocol.extensions.shim;
using agsXMPP.protocol.x;
using agsXMPP.protocol.x.data;
using agsXMPP.Xml;
using agsXMPP.Xml.Dom;
using System.Threading;
using System.Diagnostics;
namespace JabberTestCF2
{
public partial class Form1 : Form
{
private XmppClientConnection XmppCon;
private string txtJid = "xyz@gmail.com";
private string txtPassword = "abc";
public Form1()
{
InitializeComponent();
}
public void MainInit()
{
JabberInit();
Connect();
}
private void Connect()
{
Jid jid = new Jid(txtJid);
XmppCon.Open(jid.User, txtPassword);
}
private void Disconnect()
{
XmppCon.Close();
}
private void JabberInit()
{
// initilaize XmppConnection and setup all event handlers
Jid jidSender = new Jid(txtJid);
XmppCon = new XmppClientConnection(jidSender.Server);
if (jidSender.Server == "gmail.com")
{
XmppCon.ConnectServer = "talk.google.com";
}
XmppCon.AutoResolveConnectServer = false;
XmppCon.OnError += new ErrorHandler(XmppCon_OnError);
XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);
XmppCon.OnPresence += new PresenceHandler(XmppCon_OnPresence);
XmppCon.OnMessage += new MessageHandler(XmppCon_OnMessage);
XmppCon.ClientSocket.OnReceive += new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnReceive);
XmppCon.ClientSocket.OnSend += new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnSend);
}
#region << XmppConnection events >>
private void XmppCon_OnPresence(object sender, Presence pres)
{
#if DEBUG
Debug.WriteLine(String.Format("Received Presence from:{0} show:{1} status:{2}", pres.From.ToString(), pres.Show.ToString(), pres.Status));
#endif
}
private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
#if DEBUG
Debug.WriteLine(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString()));
Debug.WriteLine(msg.Body);
#endif
}
private void XmppCon_OnClose(object sender)
{
#if DEBUG
Debug.WriteLine("OnClose");
#endif
}
private void XmppCon_OnError(object sender, Exception ex)
{
#if DEBUG
Debug.WriteLine("OnError");
Debug.WriteLine(ex.StackTrace.ToString());
#endif
}
void XmppCon_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
{
#if DEBUG
Debug.WriteLine("OnAuthError");
Debug.WriteLine(e.ToString());
#endif
}
#endregion
private bool ClientSocket_OnValidateCertificate(Org.BouncyCastle.Asn1.X509.X509CertificateStructure[] certificates)//, int[] certificateErrors)
{
return true;
}
private void ClientSocket_OnReceive(object sender, byte[] data, int count)
{
#if DEBUG
Debug.WriteLine("ClientSocket_OnReceive");
Debug.WriteLine(System.Text.Encoding.Default.GetString(data, 0, count));
#endif
}
private void ClientSocket_OnSend(object sender, byte[] data, int count)
{
#if DEBUG
Debug.WriteLine("ClientSocket_OnSend");
Debug.WriteLine(System.Text.Encoding.Default.GetString(data, 0, count));
#endif
}
}
}
Thanks for your help.
Output leading upto the exception
IPV4
Waiting...
ClientSocket_OnSend
<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
ClientSocket_OnReceive
<?xml version="1.0" encoding="UTF-8"?><stream:stream from="gmail.com" id="9E0F7E9D6A02CC5E" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
The thread 0x565f12ea has exited with code 0 (0x0).
ClientSocket_OnSend
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
ClientSocket_OnReceive
<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>
ClientSocket_OnSend
<presence><status /><priority>5</priority></presence>
ClientSocket_OnSend
<stream:stream to='gmail.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
ClientSocket_OnReceive
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechani
ClientSocket_OnSend
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
ClientSocket_OnReceive
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
OnError
A first chance exception of type 'System.IO.EndOfStreamException' occurred in crypto.dll
at Org.BouncyCastle.Crypto.Tls.TlsUtilities.ReadUint8()
at Org.BouncyCastle.Crypto.Tls.RecordStream.ReadData()
at Org.BouncyCastle.Crypto.Tls.TlsProtocolHandler.Connect()
at agsXMPP.net.ClientSocket.StartTls()
at agsXMPP.XmppClientConnection.StreamParserOnStreamElement()
at agsXMPP.Xml.StreamParser.DoRaiseOnStreamElement()
at agsXMPP.Xml.StreamParser.EndTag()
at agsXMPP.Xml.StreamParser.Push()
at agsXMPP.XmppConnection.SocketOnReceive()
at agsXMPP.net.BaseSocket.FireOnReceive()
at agsXMPP.net.ClientSocket.EndReceive()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
---
Here is the full code..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using agsXMPP;
using agsXMPP.protocol;
using agsXMPP.protocol.iq;
using agsXMPP.protocol.iq.disco;
using agsXMPP.protocol.iq.roster;
using agsXMPP.protocol.iq.version;
using agsXMPP.protocol.client;
using agsXMPP.protocol.extensions.shim;
using agsXMPP.protocol.x;
using agsXMPP.protocol.x.data;
using agsXMPP.Xml;
using agsXMPP.Xml.Dom;
using System.Threading;
using System.Diagnostics;
namespace JabberTestCF2
{
public partial class Form1 : Form
{
private XmppClientConnection XmppCon;
private string txtJid = "xyz@gmail.com";
private string txtPassword = "abc";
public Form1()
{
InitializeComponent();
}
public void MainInit()
{
JabberInit();
Connect();
}
private void Connect()
{
Jid jid = new Jid(txtJid);
XmppCon.Open(jid.User, txtPassword);
}
private void Disconnect()
{
XmppCon.Close();
}
private void JabberInit()
{
// initilaize XmppConnection and setup all event handlers
Jid jidSender = new Jid(txtJid);
XmppCon = new XmppClientConnection(jidSender.Server);
if (jidSender.Server == "gmail.com")
{
XmppCon.ConnectServer = "talk.google.com";
}
XmppCon.AutoResolveConnectServer = false;
XmppCon.OnError += new ErrorHandler(XmppCon_OnError);
XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);
XmppCon.OnPresence += new PresenceHandler(XmppCon_OnPresence);
XmppCon.OnMessage += new MessageHandler(XmppCon_OnMessage);
XmppCon.ClientSocket.OnReceive += new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnReceive);
XmppCon.ClientSocket.OnSend += new agsXMPP.net.ClientSocket.OnSocketDataHandler(ClientSocket_OnSend);
}
#region << XmppConnection events >>
private void XmppCon_OnPresence(object sender, Presence pres)
{
#if DEBUG
Debug.WriteLine(String.Format("Received Presence from:{0} show:{1} status:{2}", pres.From.ToString(), pres.Show.ToString(), pres.Status));
#endif
}
private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
#if DEBUG
Debug.WriteLine(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString()));
Debug.WriteLine(msg.Body);
#endif
}
private void XmppCon_OnClose(object sender)
{
#if DEBUG
Debug.WriteLine("OnClose");
#endif
}
private void XmppCon_OnError(object sender, Exception ex)
{
#if DEBUG
Debug.WriteLine("OnError");
Debug.WriteLine(ex.StackTrace.ToString());
#endif
}
void XmppCon_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
{
#if DEBUG
Debug.WriteLine("OnAuthError");
Debug.WriteLine(e.ToString());
#endif
}
#endregion
private bool ClientSocket_OnValidateCertificate(Org.BouncyCastle.Asn1.X509.X509CertificateStructure[] certificates)//, int[] certificateErrors)
{
return true;
}
private void ClientSocket_OnReceive(object sender, byte[] data, int count)
{
#if DEBUG
Debug.WriteLine("ClientSocket_OnReceive");
Debug.WriteLine(System.Text.Encoding.Default.GetString(data, 0, count));
#endif
}
private void ClientSocket_OnSend(object sender, byte[] data, int count)
{
#if DEBUG
Debug.WriteLine("ClientSocket_OnSend");
Debug.WriteLine(System.Text.Encoding.Default.GetString(data, 0, count));
#endif
}
}
}