dotnet / aspire

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

Support proxy-less endpoints #1637

Closed davidfowl closed 8 months ago

davidfowl commented 10 months ago

This issue outlines how networking works in aspire https://github.com/dotnet/docs-aspire/issues/232. Today we spin up a proxy for each endpoint which means the application being proxied needs to be amenable to accepting a port to listen on. The proxy is important for 2 reasons:

  1. We can avoid forwarding the connection until the underling endpoint is ready
  2. We can route to multiple replicas of the underlying service

The scenario that does not work is the one described here https://github.com/dotnet/docs-aspire/issues/232#issuecomment-1884575748

We have also a legacy java http service running on specific port on Windows. We add the service as a console project managing its execution. How can I specify its port in WithServiceBinding if it is not running in a container? If i set the hostPort to the service port, the proxy blocks the port and the service cannot be started.

In this scenario, there can be no proxy because the underlying process can't listen to anything but the port it already has. The only work around for this today is to avoid using WithEndpoint (formerly WithServiceBinding) but that breaks the ability to add references to other resources (WithReference) and it also means the dashboard doesn't show the url for the service.

Open questions:

DamianEdwards commented 10 months ago

Does DCP already support a way to disable proxying or will this require work there too?

mitchdenny commented 10 months ago

I think that perhaps proxy support is a per endpoint option rather than a per resource option. So perhaps we could do something like this:

WithEndpoint(....other args..., bool? proxy = true)

@karolz-ms can comment on whether DCP still supports proxyless executables/containers.

karolz-ms commented 10 months ago

Yes, DCP supports proxyless mode. It currently designed for singletons, but could be enhanced to support replicated services too.

mitchdenny commented 10 months ago

@JamesNK

davidfowl commented 9 months ago

Giving this to you @JamesNK

davidfowl commented 9 months ago

I think the design here needs to be based on the resource itself being proxyless. It solves many of the ambiguities.