dth8312 2016-07-04 22:29
浏览 314
已采纳

Paho MQTT Golang协议

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 2016-07-05 06:25
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 Ubuntu开机显示器只显示kernel,是没操作系统(相关搜索:显卡驱动)
  • ¥15 VB.NET如何绘制倾斜的椭圆
  • ¥15 arbotix没有/cmd_vel话题
  • ¥20 找能定制Python脚本的
  • ¥15 odoo17的分包重新供应路线如何设置?可从销售订单中实时直接触发采购订单或相关单据
  • ¥15 用C语言怎么判断字符串的输入是否符合设定?
  • ¥15 通信专业本科生论文选这两个哪个方向好研究呀