swifter icon indicating copy to clipboard operation
swifter copied to clipboard

Issues stopping server on tvOS 18

Open PlasmaSoftUK opened this issue 7 months ago • 1 comments

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?

PlasmaSoftUK avatar Jun 17 '25 17:06 PlasmaSoftUK

Looks like this may just be an issue in the tvOS simulator, I will do some further on device testing.

PlasmaSoftUK avatar Jun 19 '25 22:06 PlasmaSoftUK