BrowserSockets are a proposed way to allow web pages to listen for incoming WebSocket connections using Javascript.

To make use of BrowserSocket an application developer needs to write a connection handler, include it in a web page, and register the handler with the browser using the javascript API.

After registering a handler, the web page is able to receive connections on some TCP port for all WebSocket resources having some prefix. For security reasons the web page has no control over the selection of the prefix or the port, instead these are decided by the browser.

The BrowserSocket proposal has been implemented as a proof-of-concept Firefox extension.

Usage Example

Embedding a minimal echo service in a web page is done as follows.

  1. define a connection handler function EchoHandler() { this.onmessage = function(msg) { this.send(; } }
  2. define a connection handler factory function echoHandlerFactory() { return new EchoHandler(); }
  3. register the connection handler factory with the browser var bs = new BrowserSocket(echoHandlerFactory);
  4. get an address which clients can connect to var address = 'ws://' + bs.port + bs.resourcePrefix;

Security News

Public bikes in Copenhagen locked up by a hacker

The recent incident that took place in Copenhagen showed that a click of a mouse could disrupt an entire public system.