Comments (7)
Hello @chkr1011,
First of all thank you for the library: it is a great work.
I started using it from version 3.x
Regarding your question: I pass the host as string and the port as int.
from mqttnet.
@daframax Please try this version from mygetfeed and let me know if it works: https://www.myget.org/feed/mqttnet/package/nuget/MQTTnet/4.3.4.1116
from mqttnet.
@daframax Are you using an DNS host address in the WithTcpServer method or an IP address (as string)?
from mqttnet.
Thank you @chkr1011 I will try it and let you know as soon as possibile
from mqttnet.
I figured out that the issue is related to Mono. It handles the DnsEndpoint differently than .NET Framework does. When using the overload with host and port it works perfectly.
Build: 4.3.4.1133 contains the fix if you want to test.
I will add a workaround for that and release a new version soon.
from mqttnet.
Hello @chkr1011 Thank you for your time.
I was about to report the same thing after testing the version 4.3.4.1116.
I noticed that one of differences between version 4.3.3.952 and 4.3.4.1084 was the ctor into the class CrossPlatformSocket. So I check the source code of the implementation of the class Socket.cs inside the mono repo on github and I noticed that there are differences:
Method socket.ConnectAsync(string host, int port) uses:
public IAsyncResult BeginConnect (string host, int port, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
if (host == null)
throw new ArgumentNullException ("host");
if (addressFamily != AddressFamily.InterNetwork && addressFamily != AddressFamily.InterNetworkV6)
throw new NotSupportedException ("This method is valid only for sockets in the InterNetwork and InterNetworkV6 families");
if (port <= 0 || port > 65535)
throw new ArgumentOutOfRangeException ("port", "Must be > 0 and < 65536");
if (is_listening)
throw new InvalidOperationException ();
var sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
Port = port
};
var dnsRequest = Dns.GetHostAddressesAsync (host);
dnsRequest.ContinueWith (t => {
if (t.IsFaulted)
sockares.Complete (t.Exception.InnerException);
else if (t.IsCanceled)
sockares.Complete (new OperationCanceledException ());
else {
sockares.Addresses = t.Result;
BeginMConnect (sockares);
}
}, TaskScheduler.Default);
return sockares;
}
Method socket.ConnectAsync(EndPoint endpoint) uses:
public IAsyncResult BeginConnect (EndPoint remoteEP, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
if (remoteEP == null)
throw new ArgumentNullException ("remoteEP");
if (is_listening)
throw new InvalidOperationException ();
SocketAsyncResult sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
EndPoint = remoteEP,
};
BeginSConnect (sockares);
return sockares;
}
I will test the version 4.3.4.1133
Thank you
from mqttnet.
Please test with the released 4.3.5 version. I experienced the same issue with one of my Android apps. So, I was able to fix it.
from mqttnet.
Related Issues (20)
- Unable to use certificate in Ubuntu (TLS1.2) HOT 1
- MqttClient with TLS and client certificate works on Linux but not on windows using the latest and following samples HOT 18
- No valid replacement for the obsolete MqttClientOptionsBuilder.WithConnectionUri HOT 1
- MQTTnet.AspTestApp Fails to start HOT 1
- MQTTnet.Extensions.WebSocket4Net uses several outdated and possibly vulnerable dependencies HOT 4
- MQTT-over-Websocket connection reconnects every 30 seconds (MAUI regression) HOT 1
- Can't connect to broker using CA Cert ClientCert and Key HOT 2
- Unable to connect with Unix Socket HOT 4
- Last Will not working? HOT 2
- [FR] Protobuf HOT 4
- PublishAsync doesn't return a result nor exception HOT 4
- Restore messages per client/subscription HOT 2
- No connection could be made because the target machine actively refused it. HOT 1
- Breaking Change in MqttClientTcpOptions with 4.3.5.1141 HOT 5
- Managed MQTT client hangs when trying to disconnect using `StopAsync()` in Unity Engine HOT 4
- UWP PublishAsync forever hangs
- Event when pending ApplicationMessage was published HOT 1
- MqttClientOptionsBuilder.WithTcpServer:The “_remoteEndPoint” is missing instantiation
- Json serialized messages wont get published to the broker. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqttnet.