Skip to content

Issues stopping server on tvOS 18 #558

@PlasmaSoftUK

Description

@PlasmaSoftUK

I have tried various things and I cannot get the server to stop once its started other than to kill the app it was started from. I want to enable the server to allow a file upload then stop the server once I've uploaded that file. I assumed it would be as simple as:

server.stop()

This doesn't work, having looked at the source and checked some of the available variables, before stopping it if I check:

server.operating it is false
server.state is stopped

Even though the server is happily serving pages, it still says state is stopped, which in turn makes operating false. So when I call server.stop() the following line in HttpServerIO.swift prevents the server from stopping ...

    public func stop() {
        guard self.operating else { return }

Because of this I am unable to stop the server, I even tried making server an optional with

    var server: HttpServer?
    server = HttpServer()

then try to stop it

    server!.stop()
    server = nil

Even when it has been set to nil it is still serving pages, the only way I can get the server to stop is to kill the app. So my question is how do I stop the server on demand without killing my app?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions