Closed rfbasso closed 4 years ago
Can't say I've seen this before with wss, like you say it works OK with mosquitto and if you look through other issues raised with other brokers using wss it works without any probs so it looks like your particular broker set up, or it may be something to do with your flutter installation. I don't use flutter so I'm no expert here, to rule this out you could just run the client in a server side Dart environment and see what that does, or find out what flutter is doing, there are quite a few futter devs that use the client.
According to this question, that can be a problem with the type of certificate (self signed). I think that would be great if there is a way to accept all types of certificate, like HttpClient..
Ok, but don't forget that the security context class Dart uses for secure sockets doesn't apply to websockets, the dart.io websocket implementation here doesn't allow you to specify such things as far as I know, the API is not the same as HttpClient.
Searching for a solution, I 've considered what was said about my particular broker, and tried to change my certificate. The error change - and I can't figure out why. Looks lyke in some point, the URL protocol change from wss to https
I/flutter (27624): Mosquitto client connecting....
I/flutter (27624): 2019-02-01 12:13:53.849091 -- Authenticating with username '{user}' and password '{pass}'
I/flutter (27624): 2019-02-01 12:13:53.916486 -- SynchronousMqttConnectionHandler::internalConnect entered
I/flutter (27624): 2019-02-01 12:13:53.916841 -- SynchronousMqttConnectionHandler::internalConnect - initiating connection try 0
I/flutter (27624): 2019-02-01 12:13:53.917650 -- SynchronousMqttConnectionHandler::internalConnect - websocket selected
I/flutter (27624): 2019-02-01 12:13:53.932680 -- MqttWsConnection:: WS URL is wss://ws.my_wss_url.com:8083, protocols are [mqtt, mqttv3.1, mqttv3.11]
I/flutter (27624): 2019-02-01 12:13:56.017001 -- MqttConnection::_onError - calling disconnected callback
I/flutter (27624): Client exception - HttpException: Connection closed before full header was received, uri = https://ws.my_wss_url.com:8083
I/flutter (27624): 2019-02-01 12:13:56.024014 -- SynchronousMqttConnectionHandler::disconnect
When I try with the port unencrypted, without any certificate, the connection works perfectly. Maybe could be a problem with this certificate?
Well yes, always a possibility, you may be better asking the Dart guys here, the client uses the API as exposed by Dart, the magic behind all this is performed in the Dart runtime, maybe it uses an underlying HttpClient socket and upgrades it somehow.
Also it may be worth trying your broker with another client, e.g. the paho or mosqiutto clients for instance, see what they think.
Well yes, always a possibility, you may be better asking the Dart guys here, the client uses the API as exposed by Dart, the magic behind all this is performed in the Dart runtime, maybe it uses an underlying HttpClient socket and upgrades it somehow.
Also it may be worth trying your broker with another client, e.g. the paho or mosqiutto clients for instance, see what they think.
I've tried with different clients, incluing Paho Mqtt Spy, and works perfectly, with the 2 certificates.
Now I use https://www.cloudmqtt.com/ to create a simple mqtt project.Use the connection of websocket.In mqttBox, the connection is success But in flutter,it occurs this error: I am a chinese developer. The flutter version is 1.8.1-pre23. In 1.7.x,it wouldn't happend,and your exampleis running success.But the when flutter version upgrade, your example can't run success.
This lokos like a flutter error which version of the mqtt client are you using ?
This lokos like a flutter error which version of the mqtt client are you using ?
Your thoughts are the same as mine。So I try to use the flutter branch of stable which the version is 1.7.8+hotfix.3。It didn't work.
When you write this plugins,the flutter version is ?
I have tried flutter version 1.6.0, 1.7.11, 1.7.10, 1.7.0, use your example ,it didn't connect successful.
The client is a server side package which you can use in flutter of course. The example was supplied by another contributor I don't develop in flutter its rather dated now as I don't maintain it. I suggest you take the latest client and version of flutter and implement it from scratch without using the example and see how you go.
The client is a server side package which you can use in flutter of course. The example was supplied by another contributor I don't develop in flutter its rather dated now as I don't maintain it. I suggest you take the latest client and version of flutter and implement it from scratch without using the example and see how you go.
Thanks you for your guidance! I'll try by myself.
The client is a server side package which you can use in flutter of course. The example was supplied by another contributor I don't develop in flutter its rather dated now as I don't maintain it. I suggest you take the latest client and version of flutter and implement it from scratch without using the example and see how you go.
I use flutter clean in command, all problems are fixed.But the wss I haved connected never successful.
I am also having no luck connecting to wss:// with different versions of mqtt-spy including 1.0.1 b18.
When try to connect to a WSS, I'm getting this exception:
But the WSS connection on test.mosquitto.org works perfectly..