NetMQ version introduced Stream socket type, which added the ability to read raw data from a TCP socket.
Today I want to introduce what you can do with Stream socket type and what I think could be a great development for NetMQ.

Let’s start with NetMQ.WebSockets, NetMQ.WebSockets is an extension to NetMQ which adds WebSocket transport as an extension.

Because NetMQ doesn’t have a pluggable transport feature, NetMQ.WebSockets actually wraps NetMQ and provides a new socket object which has a very similar interface as the NetMQ socket.
NetMQ.WebSockets currently implements only Router and Publisher patterns.

So who can communicate with NetMQ.WebSockets? Time to introduce JSMQ.

JSMQ is a NetMQ/ZeroMQ client in javascript whose API is very similar to other zeromq bindings and can communicate with NetMQ.WebSockets.

Now some of the C/C++ or even Java gurus need to throw down the gauntlet and implement WebSocket extension for zeromq/JeroMQ and then we will have a javascript library that can talk to all zeromq implementations.

You can find the projects on github:

You can download both JSMQ and NetMQ.WebSockets from nuget (make sure to choose prerelease) or visit there pages:

And now let’s see some examples:

NetMQ.WebSockets example

static void Main(string[] args)
  using (NetMQContext context = NetMQContext.Create())
    using (WSRouter router = context.CreateWSRouter())
    using (WSPublisher publisher = context.CreateWSPublisher())
      router.ReceiveReady += (sender, eventArgs) =>
        byte[] identity = eventArgs.WSSocket.Receive();
        string message = eventArgs.WSSocket.ReceiveString();
      Poller poller = new Poller();

JSMQ example

Javascript File

var dealer = new JSMQ.Dealer();
// we must wait for the dealer to be connected before we can send messages, 
// any messages we are trying to send while the dealer is not connected will be dropped
dealer.sendReady = function() {
    document.getElementById("sendButton").disabled = "";
var subscriber = new JSMQ.Subscriber();
subscriber.onMessage = function (message) {
   // we ignore the first frame because it's topic
   document.getElementById("chatTextArea").value =
     document.getElementById("chatTextArea").value +
     message.popString()  + "\n";
dealer.onMessage = function (message) {
    // the response from the server
function send() {
   var message = new JSMQ.Message();


<textarea id="chatTextArea" readonly="readonly"></textarea> 
<input id="messageTextBox" type="text" value="" /> 
<button id="sendButton" onclick="javascript:send();" disabled="disabled"> Send </button>