BOSH prebind in MatriX and attach to Strophe

Why prebind and attach?

When your web application is already logged in and needs to establish a XMPP connection you have a seamless and secure solution with prebind and attach. You don’t have to ask the user to provide the credentials again, and you don’t have to render the credentials insecure in your HTML output.

Prebind with MatriX

This code shows how to prebind a session with MatriX. On success MatriX raises the OnPrebind event and provides the Jid, Rid and Sid in the PrebindEventArgs. The Rid is the last one used by MatriX and must be incremented before getting passed to Strophe.
You can render this params in a new page and attach the session with Strophe.

var xmppClient = new XmppClient
	Username = "testuser",
	XmppDomain = "",
	Password = "secret",
	Transport = Matrix.Net.Transport.BOSH,
	Uri = new System.Uri("")

// subscribe to the prebind event
xmppClient.OnPrebind += client_OnPrebind;

void client_OnPrebind(object sender, PrebindEventArgs e)
	prebindArgs = e;
// start prebinding with MatriX now

You can download a complete ASP .NET example project here:
Bosh Prebind Example

MatriX XMPP library for iOS and Android available

MatriX XMPP library for iOS and Android is in Beta status now. Both versions are based on MonoTouch and Mono for Android from Xamarin.

Using this technology you can easily port your existing MatriX based c# XMPP apps to iOS and Android and resuse most of your existing code and business logic.

When you are interested in Beta testing then please contact us.

Microsoft adds XMPP support to Windows Live Messenger

This are great news for the XMPP community. Microsoft has added XMPP client support to their Windows Live servers. You can read the announcement here.

Microsoft does not support any of the mandatory SASL mechanisms SCRAM, DIGEST-MD5 and PLAIN. Instead they have implemented their own X-MESSENGER-OAUTH2 SASL mechanism. This means that all existing XMPP Software is not able to connect to their server without code changes or updates.

I have updated the MatriX library to support the X-MESSENGER-OAUTH2 SASL mechanism. You can download the latest binary here.

Here is an example how you can connect to Windows Live Messenger with MatriX.
The XMPP domain is Microsoft has the proper SRV records, so MatriX discovers the hostname automatically. All you have to do is subscribe to the OnBeforeSasl event and disable the the automatic SASL mechanism selection and choose the X_MESSENGER_OAUTH2 mechanism for authentication. Additional you have to pass SaslProperties which include your access token.

var xmppClient = new XmppClient {XmppDomain = ""};
xmppClient.OnBeforeSasl += xmppClient_OnBeforeSasl;

private void xmppClient_OnBeforeSasl(object sender, SaslEventArgs e)
	e.Auto = false;

	const string ACCESS_TOKEN = "your_access_token";
	e.SaslMechanism = SaslMechanism.X_MESSENGER_OAUTH2;
	e.SaslProperties = new LiveMessengerProperties
							   AccessToken = ACCESS_TOKEN

Of course you must retrieve your access token before you can connect with MatriX.

Some additional useful resources from Microsoft:

MatriX status update

I have not posted any updates for a while, which does not mean that there aren’t any.
So what I am working on?

There is huge progress in MatriX. Many of our customers are demanding support for special XEPs and other library extensions. So I have been working very close with them implementing many new XEPs and other useful features. I will create separate blog posts for some of these features.

Windows Phone Mango is coming now with sockets. So I have added sockets to the Windows Phone Mango version which is RTM now.

The port of MatriX to Android using mono for Android is nearly finished. You can expect a beta version very soon. Drop me an email when you are interested to join the beta test.

Whats next? Once the Android version is done I will start to work on a iOS version with MonoTouch.

You will be able to target all major mobile platform and reuse lots of your existing code and business logic.

There was no official release for a while, but the latest stable builds are always located here:

Windows Phone Mango

Today Microsoft has released the Beta Tools for Mango. Mango delivers many new features to Windows Phone developers. The two features we were waiting for are the following:

  • Background processing
  • Networking / sockets for communications

Now you are also able to use sockets instead of BOSH as transport layer on Windows Phone Mango. And your XMPP apps are able to run in background and keep your XMPP connection alive for listening asynchronous on events. This is a big step forward for XMPP and Instant Messaging apps on Windows Phone.

I have implemented sockets in MatriX for Windows Phone. You can download the MatriX beta release for Mango here.

MatriX 1.4 released

I am happy to announce release 1.4 of the MatriX XMPP libraries. There are many minor and major improvements. Here is a small list of changes

  • Silverlight version updated to Silverlight 4.0
  • added ability in Silverlight to download policies over HTTP instead of sockets (new feature in SL4)
  • try to connect to all hosts in the SRV records and all IP adresses when tehre are multiple addresses assigned (full .NET version only)
  • added DIGEST-MD5 to Silverlight and WP7 version (yes there are still many servers which require this SASL mechanism)
  • added non SASL authentication
  • XEP-0033 extended stanza addressing
You can download the new versions here.

Silverlight updates

From now all upcoming releases of MatriX for Silverlight will be compiled against Silverlight 4 because of improvements in the security policy system.

Since Silverlight 4 a connection request using sockets can choose to retrieve the policy file via the HTTP protocol on TCP port 80 instead of the custom TCP protocol on port 943. Web servers are already running in mosts environments. This makes your setup much easier because you don’t need the special policy server on port 943.

To enable policy download over HTTP use the following code in the latest MatriX for Silverlight version.

XmppClient.DownloadClientAccessPolicyViaHttp = true;

You can read more details about the Network Security Access Restrictions in Silverlight here in the MSDN

SRV Record Tester

Because many Windows users are not familiar with tools like nslookup, dig and SRV records I have created a small GUI tool to lookup XMPP SRV Records on Windows.

You can download the tool from the following link.

The .NET Framework 4 Client Profile is required to run this tool.

Screenshot - SRV Record Tester

Screenshot - SRV Record Tester

XMPP notifications for UNB

The Unclassified NewsBoard (short UNB) ist a great, fast and lightweight forums software which is very easy to extend and customize. I use it for many years now. UNB was the 1st board software with XMPP notifications for new replies in threads or users.

I have written now a small plugin which notifies board admins of new created threads. There is no need to poll the RSS feed every X minutes or hours anymore.

You can find the plugin here.

a short MatriX development update

there were no blog posts for a while because I was too very busy with coding.

I released MatriX 1.3 for .NET some days ago. This release includes many new features. To name only some of the latest updates:

  • file tranfer control
  • XPath filering
  • roster versioning
  • …..

Yesterday I successfully compiled and tested MatriX on Windows Phone 7. MatriX for Windows Phone will be the next product to complete the MatriX series released very soon.

If you plan to develop XMPP apps for WP7 or need a XMPP layer for WP7 feel free to contact me.