Replies: 8 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 |
Beta Was this translation helpful? Give feedback.
-
@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
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@davidfowl Thank you for this oddly-related resource: I updated the repo with the same steps described in the docs: |
Beta Was this translation helpful? Give feedback.
-
@davidfowl this makes we wonder whether we shouldn't have extension methods for |
Beta Was this translation helpful? Give feedback.
-
@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); |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions