Japanese Nostalgic Message Board (MQTT via HTTP/2 Demo)

Go back to example list / Go to the repository of this example on GitHub

HOST (Where is the broker):

URL:
://:/

Preset ...

SEND (Behave as a publisher):

topic =

RECV (Behave as a subscriber):

topic =

Message Board (Pick up from the subscriber):

伝言板

  a b c
1 月日 時分 ご用件
2 5/19 11:10 西新橋には先に行ってるね。by RM
3      
4      
5      
  3日過ぎたものは消します。

This HTML program (re)writes the message into the message board after the above subscriber has received the following command.

write xy msg
x
Column Code: For instance, "a" means the date column because the column is at the leftmost and has the code "a." You have to specify with a row number in practice, like that "a1."
y
Row Number: For instance, "1" means the head line of the table because the head line is numbered one. You have to specify with a column code in practice, like that "a1."
msg
Message Text: You can contain space characters in the body of the text. And if you omit the whole part of the message text, the content in the corresponding cell will be erased.

README (What is this?):

This is a control panel for testing the EventSource class, which is for the "Server-Sent Event (SSE)." This class is helpful for your web browser to work as an MQTT subscriber, as it enables server-push data transmission within HTTP regulations. And HTTP/2 is necessary to make the class truly practical. HTTP/2 can make HTTP data transmission both upstream and downstream more efficiently with a single connection.

This control panel runs the mosquitto_pub/mosquitto_sub command in a CGI script on the web server by using the EventSource class and the fetch() method. The Mosquitto commands encapsulate/decapsulate MQTT data, instead of the web client, so that this page can work as not only an MQTT subscriber but also an MQTT publisher.

Try to use me by the following steps.

How to Use Me:

0-1) [PREP.] Install a HTTP/2 web server

Typically, I recommend Apache or nginx.

0-2) [PREP.] Install Mosquitto

The installation instructions are on this page.Then, Copy and save the following text as the file "mosquitto.local.conf" in your favor directory.

0-3) [PREP.] Git clone this repository into a public web space on your web server

1) Start an MQTT broker

Type the following command on your UNIX terminal.

2) Select the MQTT broker

In the "HOST" section, fill in the URL form (Specify "mqtt://localhost:1883/" to use the above MQTT broker, of course, it's OK to use another broker. If you do so, replace "localhost" in the latter explanations with the other host you specified.)

3) Start subscribing

Move to the "RECV" section. And decide on the MQTT topic name for this trial. Next, type the topic name into the "topicname" field in this section and push the "Start" button in the same section.

4) Publish a message rewriting command

Publish a message rewriting command on your UNIX terminal with the same topic name and to the same MQTT broker as what you specified in this HTML, like this:

Then you can see the message you published on the message board.

Or you can also publish the same rewriting command from the publisher in the "SEND" section on this HTML.