我正在尝试使MQTT订阅者在VB.NET中工作。我正在使用M2MQTT来达到这个目的。以下是代码。
Sub client_MqttMsgPublishReceived(sender As Object, e As
MqttMsgPublishEventArgs)
MsgBox(e.Message())
MsgBox(e.Message)
End Sub
测试代码
Dim k As New MqttClient("broker.hivemq.com", 1883, False, New
X509Certificate)
MsgBox(k.Settings.Port())
Dim clientId As String = Guid.NewGuid().ToString()
AddHandler k.MqttMsgPublishReceived, AddressOf client_MqttMsgPublishReceived
k.Connect(clientId, "test", "test")
k.Subscribe(New String() {"start"}, Encoding.UTF8.GetBytes(MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE))
MsgBox(k.IsConnected())
因此IsConnected()在此代码中返回false。我做错了什么?