mohaqeq / M2MqttDotnetCore

MQTT client based on M2Mqtt 4.3.0 for .NETStandard 1.5
19 stars 8 forks source link

MqttClient.Connect() hangs when there is no connection #2

Open imetallica opened 7 years ago

imetallica commented 7 years ago

Hey, when I try to call connect when there is no connection, the function hangs, even when the MQTT goes back online.

Example (with F#)

let conn = MqttClient(IPAddress.Parse("127.0.0.1"))
let result = conn.Connect("hello-world") // <-- Hangs here.

I'm using dotnetcore 2.0

mohaqeq commented 7 years ago

Set the timeout and try again.

imetallica commented 7 years ago

Can you give a small example? I couldn't find any documentation about it.

Enviado do meu iPhone

Em 13 de set de 2017, às 02:47, Hamidreza Mohaqeq notifications@github.com escreveu:

Set the timeout and try again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

mohaqeq commented 7 years ago

There is class named MqttSettings. You can set the default connection time out in the singleton instance "MqttSettings.Instance" before creating client.

imetallica commented 7 years ago

Yeah, that would work if the modification access wasn't internal.

...
public int TimeoutOnConnection { get; internal set; }
...

Can you change the access modification and push a new version to nuget?

mohaqeq commented 7 years ago

I know it is internal. Please clone this code and modify it to check if it solve your problem.