mqttPaho alternatives and similar packages
Based on the "Networking" category.
Alternatively, view mqttPaho alternatives based on common mentions on social networks and blogs.
-
fasthttp
Package fasthttp is a fast HTTP implementation for Go, up to 10 times faster than net/http -
gnet
⚡️A high-performance, lightweight, nonblocking, event-loop networking library written in pure Go.🔥 -
fortio
Load testing library and command line tool and web UI. Allows to specify a set query-per-second load and record latency histograms and other useful stats and graph them. -
go-getter
A Go library for downloading files or directories from various sources using a URL. -
sftp
Package sftp implements the SSH File Transfer Protocol as described in https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt. -
NFF-Go
Framework for rapid development of performant network functions for cloud and bare-metal. -
gev
gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. -
vssh
Go library for building network and server automation over SSH protocol. -
peerdiscovery
Pure Go library for cross-platform local peer discovery using UDP multicast. -
raw
Package raw enables reading and writing data at the device driver level for a network interface. -
gmqtt
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1. -
gNxI
A collection of tools for Network Management that use the gNMI and gNOI protocols. -
ethernet
Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. -
jazigo
Jazigo is a tool written in Go for retrieving configuration for multiple network devices. -
xtcp
A TCP Server Framework with simultaneous full duplex communication,graceful shutdown,custom protocol. -
sslb
It's a Super Simples Load Balancer, just a little project to achieve some kind of performance. -
VncProxy
An RFB proxy, written in go that can save and replay FBS files -
nbio
High-performance, non-blocking, event-driven, easy-to-use, least-dependency networking framework written in Go.
Scout APM - Leading-edge performance monitoring starting at $39/month
Do you think we are missing an alternative of mqttPaho or a related project?
README
Eclipse Paho MQTT Go client
This repository contains the source code for the Eclipse Paho MQTT 3.1/3.11 Go client library.
This code builds a library which enable applications to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages.
This library supports a fully asynchronous mode of operation.
A client supporting MQTT V5 is also available.
Installation and Build
The process depends upon whether you are using modules (recommended) or GOPATH
.
Modules
If you are using modules then import "github.com/eclipse/paho.mqtt.golang"
and start using it. The necessary packages will be download automatically when you run go build
.
Note that the latest release will be downloaded and changes may have been made since the release. If you have
encountered an issue, or wish to try the latest code for another reason, then run
go get github.com/eclipse/[email protected]
to get the latest commit.
GOPATH
Installation is as easy as:
go get github.com/eclipse/paho.mqtt.golang
The client depends on Google's proxy package and the websockets package, also easily installed with the commands:
go get github.com/gorilla/websocket
go get golang.org/x/net/proxy
Usage and API
Detailed API documentation is available by using to godoc tool, or can be browsed online using the pkg.go.dev service.
Samples are available in the cmd
directory for reference.
Note:
The library also supports using MQTT over websockets by using the ws://
(unsecure) or wss://
(secure) prefix in the
URI. If the client is running behind a corporate http/https proxy then the following environment variables HTTP_PROXY
,
HTTPS_PROXY
and NO_PROXY
are taken into account when establishing the connection.
Troubleshooting
If you are new to MQTT and your application is not working as expected reviewing the MQTT specification, which this library implements, is a good first step. MQTT.org has some good resources that answer many common questions.
Error Handling
The asynchronous nature of this library makes it easy to forget to check for errors. Consider using a go routine to log these:
t := client.Publish("topic", qos, retained, msg)
go func() {
_ = t.Wait() // Can also use '<-t.Done()' in releases > 1.2.0
if t.Error() != nil {
log.Error(t.Error()) // Use your preferred logging technique (or just fmt.Printf)
}
}()
Logging
If you are encountering issues then enabling logging, both within this library and on your broker, is a good way to begin troubleshooting. This library can produce various levels of log by assigning the logging endpoints, ERROR, CRITICAL, WARN and DEBUG. For example:
func main() {
mqtt.ERROR = log.New(os.Stdout, "[ERROR] ", 0)
mqtt.CRITICAL = log.New(os.Stdout, "[CRIT] ", 0)
mqtt.WARN = log.New(os.Stdout, "[WARN] ", 0)
mqtt.DEBUG = log.New(os.Stdout, "[DEBUG] ", 0)
// Connect, Subscribe, Publish etc..
}
Common Problems
- Seemingly random disconnections may be caused by another client connecting to the broker with the same client identifier; this is as per the spec.
- A
MessageHandler
(called when a new message is received) must not block. If you wish to perform a long-running task, or publish a message, then please use a go routine (blocking in the handler is a common cause of unexpectedpingresp not received, disconnecting
errors). - When subscribing at QOS2 with
CleanSession
set to false it is possible that the broker will deliver retained messages beforeSubscribe
can be called. To process these messages either configure a handler withAddRoute
or set aDefaultPublishHandler
. - Loss of network connectivity may not be detected immediately. If this is an issue then consider setting
ClientOptions.KeepAlive
(sends regular messages to check the link is active). - Brokers offer many configuration options; some settings may lead to unexpected results. If using Mosquitto check
max_inflight_messages
,max_queued_messages
,persistence
(the defaults may not be what you expect).
Reporting bugs
Please report bugs by raising issues for this project in github https://github.com/eclipse/paho.mqtt.golang/issues
A limited number of contributors monitor the issues section so if you have a general question please consider the resources in the more information section (your question will be seen by more people, and you are likely to receive an answer more quickly).
We welcome bug reports, but it is important they are actionable. A significant percentage of issues reported are not resolved due to a lack of information. If we cannot replicate the problem then it is unlikely we will be able to fix it. The information required will vary from issue to issue but consider including:
- A Minimal, Reproducible Example. Providing an example
is the best way to demonstrate the issue you are facing; it is important this includes all relevant information
(including broker configuration). Docker (see
cmd/docker
) makes it relatively simple to provide a working end-to-end example. - A full, clear, description of the problem (detail what you are expecting vs what actually happens).
- Details of your attempts to resolve the issue (what have you tried, what worked, what did not).
- Application Logs covering the period the issue occurred.
- Broker Logs covering the period the issue occurred.
It is important to remember that this library does not stand alone; it communicates with a broker and any issues you are seeing may be due to:
- Bugs in your code.
- Bugs in this library.
- The broker configuration.
- Bugs in the broker.
- Issues with whatever you are communicating with.
When submitting an issue please ensure that you provide sufficient details to enable us to eliminate causes outside of this library.
Contributing
We welcome pull requests but before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Contributor Agreement (ECA) and sign off on the Eclipse Foundation Certificate of Origin.
More information is available in the Eclipse Development Resources; please take special note of the requirement that the commit record contain a "Signed-off-by" entry.
More information
Discussion of the Paho clients takes place on the Eclipse paho-dev mailing list.
General questions about the MQTT protocol are discussed in the MQTT Google Group.
There is much more information available via the MQTT community site.
Stack Overflow has a range questions covering a range of common issues (both relating to use of this library and MQTT in general).