micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

cannot connect to a xamarin server

Open javirs85 opened this issue 6 years ago • 1 comments

I first tested opening a MQTT Broker APP in my phone and both simple and robust clients to connected to it flawlessly. Then I opened a Xamarin.Forms server using System.Net.Mqtt.Server and tried to connect and I get this :

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 checked where this error is coming from and it looks like is from here:

    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

But I cannot figure out what's wrong ... I guess is some configuration in the server or in the client that is not matching (like mqtt version, or auth method (I used no auth so far, to make sure everything is simple)

Can you help ?

javirs85 avatar Feb 20 '19 07:02 javirs85

same here, i am even using keepalive=60 because my broker is 2.0.12

ric96 avatar Oct 10 '21 07:10 ric96