Skip to content

Server never releases open ports #3765

@izolyomi

Description

@izolyomi

Thank you for the awesome work of actix-web authors!

Context

Trying to create a reliable application, I was using the strategy to react to unrecoverable errors by reinitializing the whole application and retry the workflow preventing a whole shutdown and process restart. The implementation went just fine until I had to add a webserver as an optional feature. No matter how I tried to shut down the HttpServer, the bound ports were never released, preventing the application from properly reinitializing.

The only related discussion I've found was in #3025 .

Expected Behavior

There should be a way to properly close the server and release the Http(s) ports bound during server initialization.
Consequently, server instances initialized later should be able to successfully bind it again.

Current Behavior

No matter how I tried closing the server by dropping the server instance, shutting it down with a ServerHandle.stop(), etc, the port was always kept bound.

Possible Solution

Maybe there is already a proper way to unbind the port, but I haven't found it anywhere in the docs as well. If it's not present yet, I think it should be added and documented.

Your Environment

I am using rustc 1.86 with actix-web 4.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions