MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

ManagedClient throwing exception when running in VS

Open githubjanson opened this issue 4 years ago • 1 comments
trafficstars

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

githubjanson avatar Mar 25 '21 09:03 githubjanson

On second thoughts, maybe this is the expected behaviour. But I should not break when those exceptions are thrown in VS.

Is that so?

githubjanson avatar Mar 25 '21 10:03 githubjanson

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.

chkr1011 avatar Dec 23 '22 15:12 chkr1011