-
Notifications
You must be signed in to change notification settings - Fork 533
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Service discovery / host name resolution does not work #6864
Comments
Yes this won’t work. Service discovery only works via the http client factory. You can however manually grab the endpoint via the naming convention via configuration |
@davidfowl Could you point me to an example, on how to use the naming conventions? I'm already naming the endpoint and using that exact name for the smtp server host name:
and
There is also a method
|
The overview doc on the app host explains the format: Related: The example in our docs for writing a custom integration is an smtp server (maildev) https://learn.microsoft.com/en-us/dotnet/aspire/extensibility/custom-hosting-integration. |
@davidfowl Thank you for this oddly-related resource: I updated the repo with the same steps described in the docs: |
@davidfowl this makes we wonder whether we shouldn't have extension methods for |
@Lyra1337 you need to get the address as a connection string, e.g.: var mail = new MailMessage("[email protected]", "[email protected]", "Test", "Test");
var mailServerConnectionUri = new Uri(app.Configuration.GetConnectionString("mailhog")
?? throw new InvalidOperationException("Missing required connection string 'mailhog' or the value provided is not a valid URI."));
var client = new SmtpClient(mailServerConnectionUri.Host, mailServerConnectionUri.Port);
client.Send(mail); |
@DamianEdwards thank you for pointing me in the right direction. After changing the code according to your suggestion, it's working properly. To clarify things for the future and provide additional documentation for users with the same misunderstanding, I'll point out my learnings:
The well known endpoint names are suggestions to the container names, to be used by aspire when deploying to kubernetes or docker-compose (via aspir8). In the local development, those container won't be created and instead used routed via localhost to speed up the developer debug-loop. So, in production Is this correct? And then I immediately got the follow-up question: How should I provide the correct reference for the production smtp-server? An intuitive guess would be implementing a base-resource, like |
Yes, I actually started to write the document for this here dotnet/docs-aspire#2340 (comment)
What's the production server and what do you want aspire to do in this case? If you want to point an external resource (non container hosted elsewhere), then you would use |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi,
I'm unsure if this is a problem related to aspire or my understanding of the service discovery.
I'm trying to host a MailHog instance and want to send a E-Mail to it.
AppHost/Program.cs
ApiService/Program.cs:
The web interface is working fine and the server seems up.
I'm receiving a System.Net.Sockets.SocketException (0x00002AF9): No such host is known.
Here is a sample repo, which will show the issue:
https://github.com/Lyra1337/aspire-mailhog
Thank you in advance.
The text was updated successfully, but these errors were encountered: