Skip to content

Dynamic ports via code in runtime. #52244

Open
@cyberfirst-developer

Description

@cyberfirst-developer

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

In connection with YARP i need to ability to open/close ports in runtime via code.
Issue that i have custom handlers for ListenAnyIP.
I do

builder.WebHost.UseKestrel(options =>
{
    options.ListenAnyIP(80, lo => {...});
    options.ListenAnyIP(443, lo => {...});
});

I found that this is possible via configuration, but that not compatible with manual settings for kestrel.

Describe the solution you'd like

Something like request IListenManager from DI
then call

manager.StopListenAnyIP(80);
manager.StartListenAnyIP(80, (ListenOptions lo) => {...});//usual setup of port goes here

Something like this.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-kestrel

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions