dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.93k stars 480 forks source link

Endpoints registered as UDP show as TCP #6006

Open cecilphillip opened 1 month ago

cecilphillip commented 1 month ago

Is there an existing issue for this?

Describe the bug

When adding a UDP endpoint to a resource, the URI scheme is set to TCP

.WithEndpoint(ConsulResource.DnsEndpointName, ea =>
 {
  ea.Protocol = ProtocolType.Udp;
  ea.Port = dnsPort ;
  ea.TargetPort = ConsulResource.DefaultDnsPort;
})

Steps To Reproduce

Run the code above and inspect the annotations collection for the resource

Screenshot 2024-09-28 at 4 58 24 PM

Exceptions (if any)

No response

.NET Version info

Anything else?

No response

DamianEdwards commented 1 month ago

Seems like a simple issue with how we infer the scheme from the transport and protocol.

mitchdenny commented 1 month ago

This is not actually a bug. The overload of WithEndpoint which is being used here is the callback variant which is designed to be used to get at every individual property of the endpoint. The EndpointAnnotation does not automatically change the UriScheme of the endpoint if you change the protocol - thats up to the person doing the callback to set everything away from the default (which is TCP).