aws_mqtt_client - bruno-beloff/scs_analysis GitHub Wiki

docs > software repositories > scs_analysis > commands > subscribing to / publishing live data


DESCRIPTION

The aws_mqtt_client utility is used to subscribe or publish using the South Coast Science / AWS messaging infrastructure.

Documents for publication are gained from stdin by default, otherwise from the specified Unix domain socket (UDS). Likewise, documents gained from subscription are written to stdout, or a specified UDS.

Subscriptions can be specified either by a project channel name, or by an explicit messaging topic path. Documents gained by subscription may be delivered either to stdout, or to a specified Unix domain socket.

The --timed mode is provided so that the difference between the payload's recorded ('rec') datetime and the received datetime can be monitored. This is useful in assessing network performance.

The aws_mqtt_client utility requires the AWS client authorisation to operate.

Only one MQTT client should run at any one time, per TCP/IP host.

SYNOPSIS

Usage: aws_mqtt_client.py [-p UDS_PUB] [-s] { -c { C | G | P | S | X } (UDS_SUB_1) | [SUB_TOPIC_1 (UDS_SUB_1) .. SUB_TOPIC_N (UDS_SUB_N)] } [-n] [-t] [-e] [-v]

Options
--version show program's version number and exit
-h, --help show this help message and exit
-p UDS_PUB, --pub=UDS_PUB read publications from UDS instead of stdin
-s, --sub write subscriptions to UDS instead of stdout
-c CHANNEL, --channel=CHANNEL subscribe to channel
-n, --no-wrapper discard topic wrapper
-t, --timed add a field for received datetime
-e, --echo echo input to stdout (if not writing subscriptions to stdout)
-v, --verbose report narrative to stderr

EXAMPLES

aws_mqtt_client.py south-coast-science-dev/production-test/loc/1/gases
aws_mqtt_client.py -nt south-coast-science-dev/cube/loc/1/climate | node.py received payload.rec

DOCUMENT EXAMPLE - OUTPUT

Without -n flag:

{"south-coast-science-demo/brighton/loc/1/climate": {"tag": "scs-bgx-401", "rec": "2019-01-11T12:10:36Z", "val": {"hmd": 68.5, "tmp": 12.2}}}

With -n flag:

{"tag": "scs-bgx-401", "rec": "2019-01-11T12:10:36Z", "val": {"hmd": 68.5, "tmp": 12.2}}

With -t flag:

{"received": "2021-01-17T19:04:17Z", "message": {"south-coast-science-dev/cube/loc/1/climate": {"tag": "scs-bgx-401", "rec": "2021-01-17T19:04:16Z", "val": {"hmd": 36.7, "tmp": 24.1, "bar": null}}}}

With -nt flags:

{"received": "2021-01-17T19:00:27Z", "message": {"tag": "scs-bgx-401", "rec": "2021-01-17T19:00:26Z", "val": {"hmd": 36.7, "tmp": 24.0, "bar": null}}}

FILES

~/SCS/aws/aws_client_auth.json

SEE ALSO

scs_analysis/aws_client_auth
scs_analysis/aws_mqtt_control
scs_analysis/aws_topic_publisher

BUGS

When run as a background process, aws_mqtt_client will exit if it has no stdin stream.