Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Using Bosh in Matrix
Page:  1  2  next
Avatar
Jro #1
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
Subject: Bosh / Mobile 6
Is Bosh supported in the CF version of the Matrix libs?  I basically have a standard ejabbard server and am trying to simply validate bosh functionality in Matrix.

In the sample client, I have modified mnuLogin_Click in frmLogin.cs to:

        private void mnuLogin_Click(object sender, System.EventArgs e)
        {
            var jid = new Jid(txtJid.Text);

            _xmppClient.XmppDomain      = jid.Server;
            _xmppClient.Username        = jid.User;
            _xmppClient.Password        = txtPassword.Text;
            _xmppClient.Hostname        = myHostIP

            _xmppClient.Transport = Matrix.Net.Transport.BOSH;
            _xmppClient.Uri = new System.Uri("http://" + myHostIP + ":5280/http-bind/");

I would have expected the onError event to at least raise in this case, but no such luck.  No connection is made, and the XML debug outputs nothing but the initial send stream:

SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="eureka" version="1.0" >

Navigating to the URI in a browser on my WinMo6 emulator gives me the standard ejabberd mod_http_bind v1.2 web page.  I have used the same code in the .NET version of the matrix libs with no problems (per other threads in the .NET forum).
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
It should work. maybe there is a problem. I will check this and come back to you in this thread.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I can confirm that there is a problem. I am working on it now and post updates here.

Thanks,
Alex
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
found the problem. WebRequests behave different on the CF and sometimes very strange. Its fixed now.
You can get a new binary here:
http://www.ag-software.net/downloads.html

Alex
Avatar
Jro #5
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
Thanks for the quick response and action Alex.

Tested the new DLL this morning and everything worked swimmingly.
Avatar
Jro #6
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
I've begun to implement a BOSH oriented solution in a prototype, and have ran across an issue on connecting to the HTTPS BOSH ports on my xmpp servers.

I've upgraded my Openfire test server to the 3.7.0, which I believe includes the patches to get unsecure BOSH working with the matrix libs.  I have confirmed that this working insofar as connecting in my test environment, using the sample matrix client.

I've already validated the unsecure BOSH port works in ejabberd as well, per this thread.

Now I've begun moving to the HTTPS ports, and encounter the same problem in both my Openfire and Ejabberd test servers.  Ejabberd did not have the TLS secured version of its http_bind module setup, so I went ahead and added that (port 5281) and confirmed that it is working by using Pidgin to connect to my server.  I am using the default Openfire setup, patched to 3.7.0 (port 7443 in their default setup, for "secured HTTP client connections." - again, I validated that the configuration appears to be working via Pidgin.

Using the sample matrix client however, in both cases, I only receive this for XML output:

"SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="folka" version="1.0" >"

... which is then followed with 3 occurences of "A first chance exception of type 'System.Net.WebException' occurred in System.dll" in the debugger output tab and then a firing of the xmppClient OnClose event (but no OnError).

I am using the same connection block as detailed in my original opening post above, except with the following URI call:

            _xmppClient.Uri = new System.Uri("https://132.250.129.45:5281/http-bind/"); // Ejabberd

In the case of openfire, the port is simply different.  In both cases I can touch the https binds using internet explorer on the emulator itself.
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you please post the complete stacktrace of the exception?
Is it possible that the problem is related to weak or self signed SSL certificates?

Alex
Avatar
Jro #8
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
I've done some additional work after making my post to drill down into the exception.  Here is what I have:

System.Net.WebException occurred
  Message="The remote certificate has failed validation procedure."
  StackTrace:
       at System.Net.SslConnectionState.PerformClientHandShake()
       at System.Net.Connection.connect(Object ignored)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()
---
System.Net.WebException occurred
  Message="Could not establish trust relationship with remote server"
  StackTrace:
       at System.Net.HttpWebRequest.finishGetResponse()
       at System.Net.HttpWebRequest.asyncGetResponse(Object asyncResult)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()
  InnerException: System.Net.WebException
       Message="The remote certificate has failed validation procedure."
       StackTrace:
            at System.Net.SslConnectionState.PerformClientHandShake()
            at System.Net.Connection.connect(Object ignored)
            at System.Threading.ThreadPool.WorkItem.doWork(Object o)
            at System.Threading.Timer.ring()
---

It looks as if your suspicion is correct.  However, I am unsure as to how to best proceed to resolve this.
This post was edited on 2010-05-03, 22:07 by Jro.
Avatar
Alex #9
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have either install a valid SSL certificate on your server or ignore invalid SSL certificates.

Can you try to add this to your code before you connect?

  1. ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
  2.        
  3. internal class AcceptAllCertificatePolicy : ICertificatePolicy
  4. {
  5.     public AcceptAllCertificatePolicy()
  6.     {
  7.     }
  8.  
  9.     public bool CheckValidationResult(ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb)
  10.     {
  11.         return true;
  12.     }
  13. }

If this does not work I have to add it to MatriX and give you the certificate callback.

Alex
Avatar
Jro #10
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
I simply get a time out when I add the internal class and make the call to the CertificatePolicy prior to xmppClient.Open()
Avatar
Alex #11
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you try to make it public and see if CheckValidationResult gets called?
Is you server public so that I can make some tests against your server?

Alex
Avatar
Jro #12
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
CheckValidationResult was called in both instances (internal vs public class).

Sorry, I do not have a public instance of our test environment in front of me and probably will not be able to easily set one up with security.
Avatar
Jro #13
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
I switched my test environment mode back to Openfire 3.7.0 with the code fix you suggested and it appears to be working there.  I suppose I may have a configuration problem on the way I setup the secured http-bind on ejabberd that Pidgin has tolerated during my earlier validation but still causes a time out in the sample application.

Regardless, I appear to have connected successfully on the Openfire 3.7.0 using this new code block and will run some additional tests.
This post was edited on 2010-05-03, 23:07 by Jro.
Avatar
Jro #14
Member since Feb 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
Using this new configuration, every 2 minutes I am receiving vague series of time out exceptions (3), with the last XML sent as an empty send message.  I have timeouts disabled in Openfire, although I am aware of the 6 minute Openfire bug (http://www.igniterealtime.org/issues/browse/OF-341) but this occurs at the 2 minute marker.

There is literally nothing in the TextEventArgs but a simple whitespace character.  This looks vaguely like an attempt at the BOSH keepalive, but I am unsure.  If I add a straightforward timer that sends a simple presence update every minute, the above event never occurs.

The 2 exceptions that my debugger catches are identical in their report.  The second exception's stack trace differs in the debugger, and I have pasted that as well below.

System.Net.WebException occurred
  Message="The operation has timed-out."
  StackTrace:
       at System.Net.HttpWebRequest.finishGetResponse()
       at System.Net.HttpWebRequest.asyncGetResponse(Object asyncResult)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()

Debugger Stack Trace:
    System.dll!System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asyncResult = {System.Net.LazyAsyncResult}) + 0x77 bytes   
     Matrix.dll!Matrix.Net.BoshSocket.?(System.IAsyncResult ? = {System.Net.LazyAsyncResult}) + 0x2d bytes   
     System.dll!System.Net.LazyAsyncResult.InvokeCallback(bool asyncCompletion = true, object result = {"The operation has timed-out."}) + 0x1c bytes   
     System.dll!System.Net.HttpWebRequest.asyncGetResponse(object asyncResult = {System.Net.LazyAsyncResult}) + 0x21 bytes   
     mscorlib.dll!System.Threading.ThreadPool.WorkItem.doWork(object o = null) + 0x2e bytes   
     mscorlib.dll!System.Threading.Timer.ring() + 0x5e bytes
Avatar
Alex #15
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
try to set KeepAliveInterbal to -1 which disables Keep Alives.

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