shamblett / mqtt_client

A server and browser based MQTT client for dart
Other
552 stars 179 forks source link

RangeError (index): Invalid value: Not in range 0..8, inclusive: 113 #157

Closed cahyowhy closed 4 years ago

cahyowhy commented 4 years ago

sory i update my issue... now i tried to make the options is same based on mqtt.js (btw the connection in mqtt.js is suceed)

Screen Shot 2020-02-26 at 17 41 00

but tried with this lib got an error.. this is my configurations

Socket._client =
          MqttClient('mqtt.padipos.id', "hanumaniswandi1@gmail.com");
      Socket._client.keepAlivePeriod = 10;
      Socket._client.port = 443;
      Socket._client.logging(on: !true);

      Socket._client.useWebSocket = true;
      Socket._client.websocketProtocols = ['mqtt'];

      Socket._client.server = "mqtt.padipos.id";
      Socket._client.secure = true;
      Socket._client.pongCallback = () => print("pong");
      Socket._client.onConnected = () => print('conn: connected');
      Socket._client.onDisconnected = () => print('conn: disconected');

      MqttConnectMessage connectMessage = MqttConnectMessage()
          .withWillTopic("WillMsg")
          .withWillMessage("SocketConsume closed abnormally..!")
          .withWillQos(Socket._qos)
          .keepAliveFor(10)
          .withProtocolVersion(4)
          .withProtocolName('WSS')
          .withClientIdentifier("hanumaniswandi1@gmail.com")
          .authenticateAs(
              "eyJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiZGlyIn0..piuspqkRuGLjvUrxi_upVg.2tktQ70ZYVCc2Dim7AhkhY4ZW00vG-kmtmTP_wei2CZhfqFMMEVgBMYNitaxjKb9_NkXtB-S0vxpKtFL1_kU5b3DCAkeyguo9M4VTGjgWvU8_kXR_EVpZFSnnreEwwRmv-4m3NglKBMM2yeHfaAIfby6klEScq8gfxCeHDfabKTjarKo-S0vpoKjIg7s1zEX.uabEoi6jIMJgj5R4rHDr1YWRMlqdPOXGeF-wwlat5ms",
              password);

use mqtt_client: ^5.6.1

thank for your attention :)

shamblett commented 4 years ago

Don't know what you mean by dev environment or prod environment, this sounds like a flutter problem, the client doesn't change its behavior depending on its environment, the error is being generated by the Dart runtime, not the client.

cahyowhy commented 4 years ago

seems this issue is happen when i use 443 port

shamblett commented 4 years ago

Could you post the full log fromthe client connect, to use wss your server name should start with wss:// as in wss://mqtt.padipos.id I think

cahyowhy commented 4 years ago
Screen Shot 2020-02-26 at 23 30 03

got failed host lookup

shamblett commented 4 years ago

Post the log without the wss scheme

cahyowhy commented 4 years ago
Screen Shot 2020-02-27 at 10 17 57

same

cahyowhy commented 4 years ago

this is request header from browser using mqtt js

Screen Shot 2020-02-23 at 14 41 02
cahyowhy commented 4 years ago

its solved with this

Socket._client =
          MqttClient('wss://mqtt.padipos.id', "hanumaniswandi1@gmail.com");
      Socket._client.keepAlivePeriod = 30;
      Socket._client.port = 443;
      Socket._client.logging(on: true);

      Socket._client.useWebSocket = true;
      Socket._client.websocketProtocols = ['mqtt'];

      Socket._client.pongCallback = () => print("pong");
      Socket._client.onConnected = () => print('conn: connected');
      Socket._client.onDisconnected = () => print('conn: disconected');

      MqttConnectMessage connectMessage = MqttConnectMessage()
          .withWillTopic("WillMsg")
          .withWillMessage("SocketConsume closed abnormally..!")
          .withWillQos(Socket._qos)
          .keepAliveFor(30)
          .withProtocolVersion(4)
          .withProtocolName('MQTT')
          .withClientIdentifier("hanumaniswandi1@gmail.com")
          .authenticateAs(
              "eyJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiZGlyIn0..ieHSRO4s4kUp1jP0CCksHw.J4oFm9FPjZ8N5oM0FvICEIaTfaLj9TG-gst-lSHuhqz5ulGAMnh-192g-VBThDcpt-zsTr3FFFH_VEhJnhGmMBFAYRL_aKvYFMWGLTga56YWwrhvymF5qnoT76wG305DyOTJLgNhqwlu-cBGSAJ1zDKHrh2v06ES2HgwBQNqiSHGjdRDg7IT0xb1MpGFki3D.bnwWw_VoEMKHcvmsBQ37LVyssShlBK_xJlVdtMQxh2M",
              password);