我是 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/