shamblett / mqtt_client

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

WebSocket Connection Problems with MqttBrowserClient #567

Open ahma0y8g9797g8g7yitg78uyu opened 1 month ago

ahma0y8g9797g8g7yitg78uyu commented 1 month ago

I'm trying to connect to the MQTT broker using the MqttBrowserClient in my Flutter application, but I'm encountering issues.

The Broker URL: wss://test.mosquitto.org:8080/mqtt

image

After running my project, 1 error was shown in the console. It was "SecurityContext getter". After adding the first line in the connect function, the error shown in the console changed to "SecurityContext constructor". Which leads to that the app doesn't work properly. What is the solution for that?

22

shamblett commented 1 month ago

The SecurityContext is onlu used by secure sockets on the server side, not by websockets either on the server or in the client. To use secure websockets just use the wss url. Refer to the Dart API and the mqtt_browser_client example in the examples directory.

The client is working as it should, your actual problem is you are trying to introduce a dart.io based class into dart.html based client code.