Hello All,
I use below flutter code to connect to the HIVE broker via browser, however, I fail
i have no clue how to proceed
Can someone please help?
import 'package:flutter/cupertino.dart';
import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_client.dart';
MqttBrowserClient mq = MqttBrowserClient(
'ws://broker.mqttdashboard.com', 'clientz5tWzoydVL',
maxConnectionAttempts: 1);
/*
MqttBrowserClient mq = MqttBrowserClient('ws://test.mosquitto.org', 'client-1',
maxConnectionAttempts: 1);
*/
class mqttService {
final connMess = MqttConnectMessage()
.withClientIdentifier('clientIdentifier')
.withWillTopic('willtopic')
.withWillMessage('My Will message')
.startClean() // Non persistent session for testing
.withWillQos(MqttQos.atLeastOnce);
Future<MqttClientConnectionStatus?> connectToServer() async {
try {
mq.port = 8000;
mq.keepAlivePeriod = 50;
mq.connectionMessage = connMess;
mq.websocketProtocols = MqttClientConstants.protocolsSingleDefault;
var status = await mq.connect();
return status;
} catch (e) {
print("error is " + e.toString());
return null;
}
}
}
The error message I receive is
The maximum allowed connection attempts ({1}) were exceeded. The broker is
not responding to the connection request message (Missing Connection Acknowledgement?