Spinor8
Spinor8

Reputation: 1607

ZeroMQ socket pushing to a lightweight HTML5 client

My data collection system publishes data to a ZeroMQ socket.

I was hoping to graph the streaming data in a client application. I don't have a lot of experience with GUI design, so decided to opt for building a HTML5 client. A lot of the solutions I have read up involves putting in additional layers to get everything to work: such as interposing a web server to subscribe to the socket and then generate the HTML to serve to the user.

A: What is the easiest and most lightweight way to push streaming data from the ZeroMQ socket directly into a HTML5 client with the least amount of additional code? A code example would be extremely helpful.

B: Is there a javascript file that be loaded by the HTML5 page that will allow it to pick up the data from the ZeroMQ socket?

C: If that's not the possibility, what is the next simplest approach that actually does allow the data from the socket to be pushed into a HTML5 page?

Here's a mockup of the publisher.

# server.py
import zmq
from random import randrange
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:7770")
for i in range(1000):
    temperature = randrange(-80, 135)
    socket.send_string("%i" % (temperature))

Upvotes: 3

Views: 1900

Answers (1)

user3666197
user3666197

Reputation: 1

In case one has to integrate ZeroMQ signalling / messaging infrastructure,
including such infrastructure nodes, where javascript code can and has to run, the best place to start

check the available javascript bindings as published on ZeroMQ site:

There are two available in javascript segment published on ZeroMQ directly:
- first: http://zeromq.org/bindings:node-js
- another: http://zeromq.org/bindings:javascript

also kindly review the rightmost column with other available ZeroMQ bindings, that are ready for wider integration needs.

plus, besides the ZeroMQ-sockets, there is also another option:

for extended requirements coverage, the more recent ZeroMQ API provides tools for direct access to underlying sockets, via it's file descriptor. In such a case, the remote end may mirror ( implement ) the required ZeroMQ-protocol ( as per the published specification document ) in a form of a narrow-purpose fully-functional proxy to otherwise standard ZeroMQ socket protocol service.

Upvotes: 2

Related Questions