Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Error/Bug
    4. MQTT JS WS malformed packet error

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    MQTT JS WS malformed packet error

    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JanRöber last edited by

      Hallo zusammen,

      ich versuche jetzt seit ein paar Tagen wieder meine alte MQTT JS Webseite zum laufen zu bringen. Sie hat über den normalen mosquitto broker im WS mode funktioniert (Vor ca einem Jahr). Sie verbindet sich ja auch mit dem Broker, dann aber ohne da ich manuell ein Paket sende, wird schon ein "malformed packet" empfangen und die Verbindung wird wieder getrennt. Das gleiche passiert auch bei dem grundlegenden Tutorial was ich gefunden hatte:

      <html>
          <head>
              <script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
              <script type="text/javascript" language="javascript">
                  var mqtt;
                  var reconnectTimeout = 2000;
                  var host = "127.0.0.1";
                  var port = 1800;
                  var CLIENTNAME = "Client" + parseInt((Math.random()*100)).toString();
                  console.log(CLIENTNAME);
      
                  function onConnect(){
                      console.log("Connected");
      
                      mqtt.subscribe("TEST");
                      message = new Paho.MQTT.Message("Hello World");
                      message.destinationName = "Test1";
                      mqtt.send(message);
                  }
      
                  function MQTTconnect(){
                      console.log("connecting to "+ host + " " + port);
                      mqtt = new Paho.MQTT.Client(host,port,CLIENTNAME);
                      var options = {
                          timeout: 3,
                          onSuccess: onConnect
                      };
      
                      mqtt.connect(options);
                  }
              </script>
          </head>
          <body>
              <h1>Main Body</h1>
              <script>
                  MQTTconnect();
              </script>
          </body>
      </html>
      

      Hier ist noch die Meldung im Broker:

      PS C:\Users\JaRO\Programme\mosquitto> .\mosquitto.exe -c config.conf -v -p 1800
      1637919757: mosquitto version 2.0.13 starting
      1637919757: Config loaded from config.conf.
      1637919757: Starting in local only mode. Connections will only be possible from clients running on this machine.
      1637919757: Create a configuration file which defines a listener to allow remote access.
      1637919757: For more details see https://mosquitto.org/documentation/authentication-methods/
      1637919757: Opening ipv4 listen socket on port 1800.
      1637919757: Opening ipv6 listen socket on port 1800.
      1637919757: mosquitto version 2.0.13 running
      1637920513: New connection from 127.0.0.1:52138 on port 1800.
      1637920513: Client <unknown> disconnected due to malformed packet.
      1637920513: New connection from 127.0.0.1:52140 on port 1800.
      1637920513: Client <unknown> disconnected due to malformed packet.
      

      Und in der Browserkonsole bekomme ich nur folgende Response:

      Client72
      (Index):22 connecting to 127.0.0.1 1800
      mqttws31.min.js:36 WebSocket connection to 'ws://127.0.0.1:1800/mqtt' failed: 
      k._doConnect @ mqttws31.min.js:36
      k.connect @ mqttws31.min.js:31
      I.connect @ mqttws31.min.js:65
      MQTTconnect @ (Index):29
      (anonym) @ (Index):36
      mqttws31.min.js:36 WebSocket connection to 'ws://127.0.0.1:1800/mqtt' failed: 
      k._doConnect @ mqttws31.min.js:36
      k._disconnected @ mqttws31.min.js:54
      k._on_socket_error @ mqttws31.min.js:51
      (anonym) @ mqttws31.min.js:19
      

      Kennt sich hier jemand mit JS MQTT aus (Ohne Node.JS)?

      Schonmal vielen Dank!

      VG Jan

      Windows 10 21H1, 16GB RAM, CPU, Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz [Thinkpad Yoga X1]

      J 1 Reply Last reply Reply Quote 0
      • J
        JanRöber @JanRöber last edited by

        Und noch die config.conf:

        protocol websockets
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        956
        Online

        31.9k
        Users

        80.1k
        Topics

        1.3m
        Posts

        1
        2
        555
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo