Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
ANYEVENT-MQTT-SUB(1) User Contributed Perl Documentation ANYEVENT-MQTT-SUB(1)

anyevent-mqtt-sub - Perl script for subscribing to an MQTT topic

version 1.142640

  anyevent-mqtt-sub [options] topic1 [topic2] [topic3] ...

This script subscribes to one or more MQTT topics and prints any messages that it receives to stdout.

Print a brief help message.
Print the manual page.
-host A.B.C.D
The host running the MQTT service. The default is
-port NNNNN
The port of the running MQTT service. The default is 1883.
-qos N
The QoS level for the published message. The default is 0 ("MQTT_QOS_AT_MOST_ONCE").
Include more verbose output. Without this option the script only outputs errors and received messages one per line in the form:

  topic message

With one -verbose options, publish messages are printed in a form of a summary of the header fields and the payload in hex dump and text form.

With two -verbose options, summaries are printed for all messages sent and received.

-keepalive NNN
The keep alive timer value. Defaults to 120 seconds. For simplicity, it is also currently used as the connection/subscription timeout.
-count NNN
Read the specificed number of MQTT messages and then exit. Default is 0 - read forever.
-one or -1
Short for -count 1. Read one message and exit.
Ignore retained messages. That is, wait for new messages rather than processing existing retained messages.
--code CODE
Use CODE for callback. The caller is responsible for ensuring that the code to be executed is safe - i.e. not "system('rm -rf /');". The code will be called with the following arguments in @_:
The topic of the received message.
The message payload.
The Net::MQTT::Message object for the message.
A condvar that can be emitted to quit the subscribe loop.
The AnyEvent::MQTT object.
An empty hash reference that can be used as a stash.

For example:

  my ($topic, $payload, $message, $quitcv, $mqtt, $stash) = @_;
  print STDERR $topic, ': ', $payload, "\n";
  $quitcv->send if ($stash->{'count'}++ > 10);

If a callback is provided with this option then the builtin callback is no longer called.


This is not official IBM code. I work for IBM but I'm writing this in my spare time (with permission) for fun.

Mark Hindess <>

This software is copyright (c) 2014 by Mark Hindess.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2014-09-21 perl v5.32.1

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.