MQTT connections (-> "Configuration/Connections")
This page shows all existing MQTT connections. Via the context menu, you can edit and delete these or create new ones.
Lobster Integration always acts as an MQTT client and not as a server and supports MQTT 3.1.1 and MQTT 5.
See also section MQTT (Control Center).
Converting HTTP requests into MQTT messages
It is possible to transform HTTP requests into MQTT messages.
The purpose is to be able to convert a large number of HTTP requests into MQTT messages in a simple way without much logging and without many jobs and to then process them (and maybe filter them) as a single job. Example: Trucks send GPS data every 5 minutes. You would like to collect these for a period of one hour and then process them together.
Servlet
You have to insert the following servlet in configuration file ./etc/hub.xml, preferably before section <Ref id="RequestLog">.
The servlet is mounted under the context /mqtt, i.e. HTTP requests to http(s)://<URL-or-IP-of-the-Integration-Server>/mqtt/ are processed by the servlet.
<
Ref
id
=
"Contexts"
>
<
Call
name
=
"addHandler"
>
<
Arg
>
<
New
id
=
"mqtt"
class
=
"org.eclipse.jetty.servlet.ServletContextHandler"
>
<
Arg
type
=
"int"
>1</
Arg
>
<
Set
name
=
"contextPath"
>/mqtt</
Set
>
</
New
>
</
Arg
>
</
Call
>
</
Ref
>
<
Ref
id
=
"mqtt"
>
<
Call
name
=
"addServlet"
>
<
Arg
>
<
New
class
=
"org.eclipse.jetty.servlet.ServletHolder"
>
<
Set
name
=
"className"
>com.ebd.hub.datawizard.mqtt.HttpToMqtt</
Set
>
<
Set
name
=
"name"
>Http2Mqtt</
Set
>
</
New
>
</
Arg
>
<
Arg
>/*</
Arg
>
</
Call
>
</
Ref
>
Configuration file
You also need a configuration file ./etc/admin/datawizard/http2mqtt.properties. There you can define HTTP request paths (below /mqtt) and the MQTT alias and topic of the MQTT server to which the HTTP requests transformed into MQTT messages are redirected.
# path=alias:topic
# where a path like /a/b/c is used as a.b.c (no leading / and all / are replaced by .)
#
# sample:
proxy.gps=proxmox:gps
proxy.gps.separator=##new message##
Here HTTP requests (GET and POST) to path /mqtt/proxy/gps are converted into MQTT messages to topic gps of the MQTT server behind alias proxmox.
The entry <path>.separator (here proxy.gps.separator) defines a delimiter line (+NL) that is inserted before the payload. This is useful if you want to collect messages in an MQTT Input Agent (to be able to recognise what the individual messages are).
Example
The (GET) HTTP request https://<URL-or-IP-of-the-Integration-Server>/mqtt/proxy/gps?l=30&b=46&id=0815 is stored on topic gps (of the MQTT server behind alias proxmox) with the following payload.
l=30 |
The query data is separated with NL (newline) and URL-decoded. Note: With POST, the query string is inserted at the beginning, as with GET, and the body is then appended, separated with NL. URL decoding is done for ContentType "application/x-www-form-urlencoded".