Mqtt shows Unsupported operation: default SecurityContext getter in Flutter web application


I implement mqtt using HiveMQ in flutter mobile application. But when I tried to run in flutter web it shows “Unsupported operation: default SecurityContext getter”.I used “mqtt_client: ^10.0.0” package.
I saw that " browser client supports only secure(wss) and non-secure(ws) websocket connections.".But from where i get this wss for mqtt connection using hive.

My code is,
_client = MqttServerClient.withPort(
StringConstant.MqttServerUrl, ‘’, StringConstant.mqttPort);
_client.logging(on: false);
// _client.keepAlivePeriod = 20;
_client.onConnected = onConnected;
_client.onDisconnected = onDisconnected;
_client.onSubscribed = onSubscribed;
_client.onSubscribeFail = onSubscribeFail; = true;
_client.securityContext = SecurityContext.defaultContext;
_client.onBadCertificate = (dynamic a) => true;

Hello @Resma ,

Thank you for the outreach!

Could you please confirm if this is a HiveMQ Cloud broker, or a self-managed broker that we are looking to connect to? If using a HiveMQ Cloud broker, it is important to keep in mind that TLS/SSL connections are required, and it does not appear that we are providing a certificate here for the connecting client.

Are you able to successfully connect to the broker from a test client, such as the MQTT CLI tool, or the Web Client?

Additionally, our HiveMQ Cloud server certificate can be obtained from our Frequently Asked Questions section here on the community forum.

Aaron from the HiveMQ Team

Hi, Thís is a HiveMQ Cloud broker.
I am developing application using flutter. So in mobile mqtt is working fine issue is only when a run in web.
I gave Free URL and port 8883.It is working fine in mobile application. I saw that in browser we need to pass ws URL. So from where we get that?

Hi @Resma ,

The secure websocket port for the HiveMQ Cloud cluster is 8884, same URL.

best regards,
Dasha from HiveMQ Team

Hi @Daria_H ,
Thanks for the response.
But I tried this way with same url but when i am trying to connect I got “MqttBrowserWsConnection::connect - The URI supplied for the WS has an incorrect scheme”

Hello @Resma ,

Could you please provide the whole connect string that is currently being used for this connection attempt? Some libraries require an additional identifier prepended to provided URL, defining HTTP, HTTPS, or WS (websocket) connections.

Aaron from the HiveMQ Team