WebSockets Connection Manager for Openfire

This is an implementation of WebSockets for the Openfire XMPP server. It consists a plugin for Openfire and a low-level JavaScript library suitable to be used with jQuery.


Recently, I have been involved in shaping an XMPP protocol extension (XEP) for simple application remote control of telephony devices for financial trading systems. This XEP is called Openlink and is still evolving.

I use XMPP Bosh to provide an Openlink Javascript library for web based applications and I am seeking to improve performance and scalability beyond the limitations of long-polling BOSH connections, so I decided to investigate replacing BOSH with Websockets in my Openlink Javascript library.

What did you do?

The Websocket protocol is close to finalising and Jetty (the embedded web server for Openfire) has been supporting WebSocket since Nov 2009 in version 7.0.1 which is the Jetty version in current Openfire 3.7.0. My first attempt of using the Jetty WebSocketServelet? class from Openfire 3.7.0 with Google Chrome web browser failed and I am not sure why. The WebSockets specification has changed a lot over the last two years and both Chrome and Jetty have kept up with it, so I was not surprised.

I therefore decided to recompile Openfire from SVN (version 3.7.1 Alpha) with latest Jetty 7.5.1 and finally got it working.

I then implemented a very thin XMPP stanza based Javascript class called openfire-websockets which exposes a minimium “Stophe” like connection object which I tested with the XMPP console application in chapter 4 of the book “Professional XMPP Programming with JavaScript and jQuery” by Jack Moffitt.


You can use this plugin from Openfire 3.7.0. Just replace openfire.jar and slf4j-log4j12.jar in OPENFIRE_HOME\lib.

Should I?

If you do most of your application development with XMPP like I do, using Openfire and need fast and simple access to the low level XMPP messages as DOM elements in Javascript from JQuery right now, then take a look at openfire-websockets.js


1 Like

it sounds great …

Cool beans Dele, nice work! I’m curious if you’ve done any scalability testing of Websockets vs BOSH in Openfire?

Thanks Leon :slight_smile:

I have not done any testing. I am hoping someone else with the infrastructure would.

I am relying on tha fact that the Jetty WebSocket implementation is tested and matured on 7.5.1 since the original 7.0.1 implementation. Jetty with Continuations scales very well. WebSockets should benefit from that. Only testing can confirm :wink:

Do you have the patch available that made Jerry 7.5.x work with Openfire 3.7? Would like to take my OF to 3.7.1.

  1. I have no need to add that command. I get XMPP packets from the VirtualConnection class. The client application usually sets presence in order for user to become online and available
  2. You need the client to send white space (ping) messages every 20 secs. See http://code.google.com/p/openfire-websockets/source/browse/trunk/plugin/peek/ope nfire-websockets.js

this.interval = setInterval (function()

         {window.openfireWebSocket.sendRaw(" ")}, 10000 );

Hi Dele!, its really great work u’ve done here!

I managed to get it running but then im stuck with anonynous login…

Is it possible at all in this current state of plugin?

Hi Dale,

I can not get it working, here are steps I followed

Stopped openfire

Copy openfire.jar

Copy slf4j-log4j12.jar in /opt/openfire/lib/

Resterted openfire

I can not see it anywhere in GUI and also the url doesn’t work (http://openfire.ip:7070/ws)

warn.log says:

org.jivesoftware.openfire.container.PluginManager - Ignoring plugin websockets: requires server version 3.7.2

while after copying file the version is Openfire 3.7.1 Alpha

get the nightly build of openfire 3.7.2 beta from http://www.igniterealtime.org/downloads/nightly_openfire.jsp

1 Like

thanks it worked

ofChat keeps grey and unlickable after signed in

What steps will reproduce the problem?

  1. I use Openfire 3.8.2 alpha and ofchat-010 (withou websockets checked)

  2. I can sign in but ofChat keeps grey

  3. on server side i can see “only” any anonymous session for my ip, altough i logged in via my ldap user i also use with spark sucessfull.

Anonymous 452d980a Local Authenticated Online

Anonymous Login is allowed on server, however users authenticate against ldap and i logged in in ofchat with my ldap account i reagilary use with spark sucessfully.

Please help!

It will be realy awesome if you implement it without jetty…

Because today websocket is supported by tomcat and wide number of browsers. (Jetty is unnessasary and slowdown speed framework now)

Is there any progress in this direction (of using websockets with openfire)?

Is there any clear tutorial / steps how to support websockets in openfire?

sorry, no tutorial. please read the source code of openfire meetings for openfire websockets implementation

How to run websocket on server ?

I have following code to check its running or not :

WebSocket Test var wsUri = "ws://"; var output; function init() { output = document.getElementById("output"); testWebSocket(); } function testWebSocket() { websocket = new WebSocket(wsUri); websocket.onopen = function(evt) { onOpen(evt) }; websocket.onclose = function(evt) { onClose(evt) }; websocket.onmessage = function(evt) { onMessage(evt) }; websocket.onerror = function(evt) { onError(evt) }; } ..... .... .... but getting error like : **Firefox can't establish a connection to the server at ws://**