Closed FarshadX closed 4 years ago
I'm not sure, but
public async bool StartServer()
{
StartMQTTServer();
}
shouldn't even work...
You're using a bool StartServer()
method which returns bool
, but public async void StartMQTTServer()
returns void
.
I would use it like this:
public async bool StartServer()
{
try
{
await StartMQTTServer();
return true;
}
catch
{
return false;
}
}
public async Task StartMQTTServer()
{
// ... Whatever
}
Possible duplicate of https://github.com/chkr1011/MQTTnet/issues/494. Might be fixed in https://github.com/chkr1011/MQTTnet/pull/940.
@FarshadX Please set the ReuseAddress property in the server options before starting the server.
@FarshadX Specifically, set new MqttServerOptionsBuilder().Build().TlsEndpointOptions.ReuseAddress = true;
, check out my example project under https://github.com/mqttnettest/Issue872Test as well.
Not able to use the https://github.com/mqttnettest/Issue872Test
@deveshspraxa What's the issue?
Describe your question
I'm using mqttnet server to initiate a local MQTT server and receive messages in UWP programming. I initialize the server on a specific port(6616) In my scenario, I wanna stop the mqttserver and start it again after a while. I use await mqttServer.StopAsync() to stop the mqttserver. After starting the mqttserver again the application will terminate with the following exception:
so it seems that the server wasn't stopped perfectly or the socket port wasn't disposed correctly, I checked my active connection with netstat command in cmd after stopping the server and find out the related socket(port) wasn't disposed. Did I do something wrong? Is there any solution?
Which project is your question related to?