-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocket .NET 5.0 connection and publish issues #1197
Comments
I am experiencing the same kind of connection issues running a simple .net 5.0 console MQTT client against a mosquitto broker in linux via websockets. I am able to verify the websockets connectivity through a test client like https://hezhii.github.io/mqttjs-client/ , but the .net client would fail (connection time out) in 10 seconds or so. The managed client failed too. Here is the options for the managed mqtt.net websockets client I use. var options = new ManagedMqttClientOptionsBuilder()
My goal is to utilize the very same .NET 5 client code for realtime communications between web clients and desktops. One runs on destop or devices as IoT applications, and the other runs as a Blazor web app via webassembly in the browser. Would MQTT.net support this type of inter-operable scenario on the client side? |
I am experiencing a similar problem using this libs on Blazor Progressive Web Applications. I get stable connection with a broker (using VerneMQ on a local docker container) but it do not publish any message. The code Just for test, let me share my code (I used MudBlazor as web design):
|
I have the same bug as fabioGulfMike. I use MQTTnet with Websocket in a Blazor .net5.0 Webassambly app. When I use the debugger to slowly step through the Publish() code while return back into the Blazor Framework publishing works and the broker receives the messages. So in my opinion there is something wronge with the TryPublishQueuedMessageAsync. |
@sbroszat, I changed to MQTT client implemented in JavaScript and used the JS.Interop libs to build my project. Faster and more reliable. |
I have the same issue and came upon this thread |
@mvanhil if you mean Blazor: I changed also to the Paho JS MQTT Client with JS.Interop. Thanks for the hint @iotechFabio. Works without problems. |
I'm now using the default library (not the managed client) and all is working perfectly for now (just publishing). |
Describe your question
There are issues with Managed client and WebSockets, it fails (or takes a long time more than 30-60 secs) to connect and publish to a test Mosquitto broker, with .NET 5.0 on Windows 10, and fails on Mac OS X. It does work sometimes if .NET standard framework or Mono is used on Mac OS X or Linux.
I suspect platform specific code issues with the ManagedClient code (messages getting enqueued without actually being published, Task completion or threading issues?). The examples for ManagedClient here: https://dzone.com/articles/mqtt-publishing-and-subscribing-messages-to-mqtt-b and https://github.com/chkr1011/MQTTnet/wiki/ManagedClient were having these issues with dotnet core.
I managed to get the code working only using a Task completion and Task.ContinueWith() approach as shown here (@chkr1011 is this an optimal approach?):
Which project is your question related to?
The text was updated successfully, but these errors were encountered: