-
Notifications
You must be signed in to change notification settings - Fork 19
Resolve canonical_name to support "localhost" on windows #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
|
Hello and thank you very much for submitting this PR! |
|
First of all congrats on passing with condition :) I just found another case in Docker + WSL2 where localhost (with the fix applied) couldn't be resolved. So something is still amiss but I am out of my ASIO depth here. |
|
Sorry for taking so long to get back to you. I tried to replicate the issue you described on Windows 11 by installing a mosquito broker and running it locally. I compiled my client code with MSVC 14.37. I could not connect to my local broker. However, I did not find any issues with the resolver. It resolved Additionally, I tried running both the broker and the client code on WSL2 (Debian 12 distro) and encountered no issues. Therefore, I think I need more information about your situation to figure out what is going on:
Thanks! |
|
You are probably right. This would also explaing the Docker side of things within the setup I have here. I will try and check if the change to |
|
So I just tested on Windows (can't in Docker at the moment). Versions
Mosquitto Output on Startup
1731059274: mosquitto version 2.0.15 starting
1731059274: Using default config.
1731059274: Starting in local only mode. Connections will only be possible from clients running on this machine.
1731059274: Create a configuration file which defines a listener to allow remote access.
1731059274: For more details see https://mosquitto.org/documentation/authentication-methods/
1731059274: Opening ipv4 listen socket on port 1883.
1731059274: Opening ipv6 listen socket on port 1883.
Client Code boost::asio::io_context io;
auto client = std::make_shared<async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket>>(io);
auto clientId = "...";
client->brokers("localhost").keep_alive(5).credentials(clientId);
boost::asio::post(io, [client]() {
client->async_run(boost::asio::detached);
});
std::vector<async_mqtt5::subscribe_topic> topics;
topics.push_back(async_mqtt5::subscribe_topic{
"test",
async_mqtt5::subscribe_options{async_mqtt5::qos_e::exactly_once,
async_mqtt5::no_local_e::yes,
async_mqtt5::retain_as_published_e::retain,
async_mqtt5::retain_handling_e::send}});
boost::asio::post(io, [client, topics = std::move(topics)]() {
client->async_subscribe(topics,
async_mqtt5::subscribe_props{},
[](async_mqtt5::error_code,
std::vector<async_mqtt5::reason_code>,
async_mqtt5::suback_props) {
// This is never reached
});
});
auto runForeverThread = std::thread([io = &io]() {
io->run();
});
runForeverThread.join();Original Version With only PR Changes (Sorry I must have done some testing wrong when I first proposed this PR :( ) With only changes to With PR and Swapping from |
|
Thank you for the very detailed report! I noticed that the broker running in default mode listens on both IPv6 and IPv4. Additionally, when I run your code (or any other example that connects to The fact that your code works when you swap to Your config file should look like this: Run your mosquito broker with: Please try your code with |
|
First of all I tracked down one issue in the work firewall that might explain why it didn't connect at all before and I got Then I did some tests (again Windows only at the moment) With Without Hope this helps |
|
Good job on figuring it out! Hopefully, that fixes the issue on WSL2 as well. |
Summary: related to T13767, #19 Reviewers: ivica Reviewed By: ivica Subscribers: iljazovic, miljen Differential Revision: https://repo.mireo.local/D32140
|
Resolved with f80c189. |
Hi Mireo Team,
on Windows async_mqtt5 fails to resolve
localhost. Changing to a canonical resolver fixes this.