Skip to content
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

Resolve canonical_name to support "localhost" on windows #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Faaux
Copy link

@Faaux Faaux commented Oct 21, 2024

Hi Mireo Team,

on Windows async_mqtt5 fails to resolve localhost. Changing to a canonical resolver fixes this.

Copy link

codecov bot commented Oct 23, 2024

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 ☂️

@ksimicevic
Copy link
Collaborator

Hello and thank you very much for submitting this PR!
We are currently undergoing a Boost review until the end of this week. We will look at this PR next week.
Sorry for the inconvenience.

@Faaux
Copy link
Author

Faaux commented Oct 31, 2024

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.

@ksimicevic
Copy link
Collaborator

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 localhost successfully and returned 2 endpoints (IPv6 and IPv4). In my case, the issue was in connect_op.hpp:112 where we call async_connect with the first endpoint in the list (which was the IPv6 endpoint here and my broker was listening on IPv4). I fixed the issue by changing the perform function to use the free function boost::asio::async_connect that will iteratively try to connect to every endpoint in the list until it successfully establishes a connection:

void perform(
	const epoints& eps, authority_path ap
) {
	auto& stream = lowest_layer(_stream);
	asio::async_connect(
		stream, eps,
		asio::append(
			asio::prepend(std::move(*this), on_connect {}),
			std::move(ap)
		)
	);
}

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:

  1. When you said that your client failed to resolve to localhost on Windows and Docker+WSL2, does that mean you have received an error_code in resolve_op in endpoints.hpp:109? If yes, what was the resolve_ec and timer_ec?
  2. Could you precisely specify the client and broker setups where you encountered the issue (the Windows version, WSL2 distribution, and compilers used to compile your client code)?

Thanks!

@ksimicevic ksimicevic self-assigned this Nov 4, 2024
@ksimicevic ksimicevic added the bug Something isn't working label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants