go - Paho MQTT Golang 协议(protocol)

标签 go mqtt tls1.2 paho

我是 Golang 和 mqtt 的新手。

我正在尝试连接到代理。当我使用 MQTT.fx 或我的带有蚊子的终端时,它会起作用。

但在我的程序中,我使用地址和 clientID 创建我的选项,当我尝试连接时出现错误“Unknow protocol”

panic: Network Error : Unknown protocol

goroutine 1 [running]:

panic(0x347b20, 0xc820072fe0)

/usr/local/go/src/runtime/panic.go:481 +0x3e6

main.main()

test.go:29 +0x1cd

我检查了 MQTT.fx 上的协议(protocol)版本,它是 TLSv1.2。

Paho 库支持 TLS 协议(protocol)。我有点糊涂

有人遇到同样的问题吗?

干杯

最佳答案

我修好了。只是忘了在 url 的开头精确说明协议(protocol)。

The type of connection required is specified by the scheme of the connection URL set in the ClientOptions struct, for example:

tcp://iot.eclipse.org:1883 - connect to iot.eclipse.org on port 1883 using plain TCP ws://iot.eclipse.org:1883 - connect to iot.eclipse.org on port 1883 using WebSockets tls://iot.eclipse.org:8883 - connect to iot.eclipse.org on port 8883 using TLS (ssl:// and tcps:// are synonyms for tls://)

有效 :-)

关于go - Paho MQTT Golang 协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38192943/

相关文章:

go - 尝试创建问题时来自 GitHub API 422 的意外错误响应

node.js - 如何通过服务器隧道浏览器端mqtt?

ssl - GOlang/https : timeout waiting for client preface

go - 导入由 cython 生成的 c 共享库以与 cgo 一起使用

Python 和 Azure 物联网中心

运行 golang http.Client 的 Docker 容器出现错误 `certificate signed by unknown authority`

java - MobileFirst 7.1 在生产服务器上获取 "No negotiable cipher suite"- 在 Dev 上运行良好

google-chrome - Chrome 与 IE 中的 TLS 设置 - ERR_CONNECTION_RESET

go - 分配空 slice 而不引用其类型?

Azure IOT 中心发布订阅