我正在使用WinRT(Windows8 Release Preview)。我有一個Web應用程序(實際上是一個更簡單的XMPP客戶端)。使用StreamSocket升級到SSL
我主要使用StreamSocket類來連接Jabber服務器。它給了我一個很好的開始。但是當我嘗試升級已連接的套接字以使用SSL時遇到了問題。我使用StreamSocket.UpgradeToSslAsync來實現它。它拋出這樣的異常
方法在意外的時間被調用。 (異常來自HRESULT: 0x8000000E)
我不知道爲什麼會發生這種情況。作爲上述鏈接,我做了所有事情。我創建了連接成功的套接字。我可以從Jabber服務器接收一些xml節。 這是一張照片,當它運行。[1]
你可以看到圖片new tab。
當我點擊UpToSSL按鈕時,它崩潰並拋出異常,如上所述。
下面是簡單的版本代碼:
// xmpp is my CXMPP client class
private void StartTlsBtn_Click(object sender, RoutedEventArgs e)
{
xmpp.SendXml("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' />");
}
// it works fine, and i have got the reponse from server:
// <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
// next step i should upgrade my sockey connection to ssl
private void UpSslBtn_Click(object sender, RoutedEventArgs e)
{
xmpp.UpToSsl();
}
async public void UpToSsl()
{
SendEvent.WaitOne();
SendEvent.Reset();
// private StreamSocket ClientSock;
await ClientSock.UpgradeToSslAsync(SocketProtectionLevel.Ssl, ClientSock.Information.RemoteHostName);
isSsl = true;
SendEvent.Set();
}
請給我一些提示。謝謝。
您是否嘗試過與ConnectAsync連接釋放後,這種資助自己的XMPP庫將被釋放?如果你展示瞭如何創建套接字並實現文檔的備註部分中的步驟,這將有所幫助。 –
是的,實際上我使用ConnectAsync作爲MSDN說。 – zjalex