Skip to content

How do I shut down a server cleanly? #1575

@dylanede

Description

@dylanede

After spawning a server on a tokio Runtime, then shutting down the runtime (using shutdown_now), recreating a server on the same IP and port with a new Runtime panics, claiming

error creating server listener: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)

If I instead recreate the server by restarting the process, it works fine.

This behaviour is being observed on Windows 7. I have tried sleeping the thread for up to 10 seconds before recreating the server and the same error occurs.

Other than shutting down the Runtime, is there something else I must do to cleanly close a server? The documentation mentions the concept of "shutdown" in passing, but does not elaborate on what must be done to achieve that correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-serverArea: server.B-rfcBlocked: More comments would be useful in determine next steps.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions