xamarin mqtt server unaccessible

廉价感情. 提交于 2020-01-16 17:35:53

问题


Im using system.Net.mqtt in a Xamarin project. I create a server like this:

var server = MqttServer.Create();
server.ClientConnected += Debug;
server.ClientDisconnected += Debug;
server.Stopped += (o, e) => Debug($"disconnection ! {e.Message} and {e.Reason} ");

server.Start();

I have a nodeMCU coded y micropython. If I start and android MQTT broker in the phone I CAN connect to it from the nodeMCU, and push and subscribe to messages. Flawless. But if I switch off the broker and start the server as stated before I get this from the nodeMCU when trying to connect:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Utils.py", line 10, in __init__
File "Utils.py", line 16, in ConnectMQTT
File "umqtt/simple.py", line 99, in connect
MQTTException: 2

I'm pretty sure the problem is that the server is not running.. or something :)

UPDATE 1:

I checked where the exection comes from, I have no idea what it means but it comes from here (Python code):

    self.sock.write(premsg, i + 2)
    self.sock.write(msg)
    #print(hex(len(msg)), hexlify(msg, ":"))
    self._send_str(self.client_id)
    if self.lw_topic:
        self._send_str(self.lw_topic)
        self._send_str(self.lw_msg)
    if self.user is not None:
        self._send_str(self.user)
        self._send_str(self.pswd)
    resp = self.sock.read(4)
    assert resp[0] == 0x20 and resp[1] == 0x02
    if resp[3] != 0:
        raise MQTTException(resp[3])   <------- Here!
    return resp[2] & 1

来源:https://stackoverflow.com/questions/54767744/xamarin-mqtt-server-unaccessible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!