Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bosh with all npm packages installed. Try it out:

var bosh = require("bosh")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bosh v0.1.2

A simple BOSH middleware


This is a simple BOSH middleware (for anything with a connect-like API), or can be used as a connection handler function for the raw node HTTP server.


var http = require('http');
var bosh = require('./bosh.js');

Example as Connect middleware

var connect = require('connect');
var urlrouter = require('urlrouter');

var app = connect();

var bosh = require('./bosh.js');

var router = urlrouter(function(app) {
    var boshHandler = bosh();'/http-bind/', boshHandler);
    app.get('/http-bind/', boshHandler);

app.use(connect.logger({ immediate: true, format: 'dev' }));




It implements just enough of the connection manager protocol at this point to pass through an XMPP session. Correctness is left for a later pass through the code. There is little to no error handling.

There's still a glitch with libpurple clients dropping connections and replacing them.

No multiple stream support yet.

No repeatable reads yet.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free