dth8312
dth8312
2016-07-04 22:29

Paho MQTT Golang协议

  • tls1.2
  • paho
  • mqtt
已采纳

I'm new on Golang and mqtt.

I'm trying to connect to a broker. It works when I'm using MQTT.fx or my terminal with mosquitos.

But in my program, I create my opts with the address & clientID and when I try to connect there is an error "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

I checked the protocol version on MQTT.fx and it's TLSv1.2.

The Paho library support TLS protocol. I'm a bit confused

Is there someone who got the same issue ?

Cheers

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanhe7471 duanhe7471 5年前

    I fixed it. Just forgot to precise the protocol at the beginning of the url.

    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://)

    That works :-)

    点赞 评论 复制链接分享

为你推荐