MQTTnet
MQTTnet copied to clipboard
ManagedClient throwing exception when running in VS
Describe your question
This only happens when running in Visual Studio. The same code works in another project. So this is most likely not an MQTTnet problem, but maybe some of you have run inte the same issue?
When calling StartAsync on ManagedClient the following exception is thrown if no MQTT server is up and running.
System.Net.Internals.SocketExceptionFactory.ExtendedSocketException: 'No connection could be made because the target machine actively refused it'.
If I select to not catch this exception, I get the following exception instead:
MQTTnet.Exceptions.MqttCommunicationException: 'Error while connecting with host 'localhost:1883'.'
Note that if I run the executable directly outside Visual Studio, everything works as expected, that is, no exception/crash even if the target server is not up and running.
Which project is your question related to?
- ManagedClient
On second thoughts, maybe this is the expected behaviour. But I should not break when those exceptions are thrown in VS.
Is that so?
Closing this due to inactivity. I personally cannot reproduce the issue. In my opinion it is related to VS exception settings and it is indeed correct that these exceptions are thrown in the described situations.