Skip to content

Client: "Address already in use” error #106

@pointum

Description

@pointum

The Client does not show the TouchBar on launch. If I go to the Home screen and reactivate the app, it starts working.

I’m running from the latest source code.

The problem is that on app launch startListening is called twice in a row:

  • -[ViewController viewDidAppear:]
  • UIApplicationDidBecomeActiveNotification notification

The second call fails with:

TouchBarClient[626:55698] Failed to listen on localhost:1337: Error Domain=NSPOSIXErrorDomain Code=48 "Address already in use”

Here’s what my print debugging looks like when I start the Client:

// -[ViewController viewDidAppear:]
stopListening: (null)
startListening: <PTChannel: 0x2824aeac0 (closed)>
listenOnPort callback: <PTChannel: 0x2824aeac0 (listening)>

// UIApplicationDidBecomeActiveNotification
stopListening: <PTChannel: 0x2824aeac0 (listening)>
startListening: <PTChannel: 0x28245db40 (closed)>
listenOnPort callback: <PTChannel: 0x28245db40 (closed)>
Failed to listen on localhost:1337: Error Domain=NSPOSIXErrorDomain Code=48 "Address already in use"

Maybe a fix should be to check if is already listening and then skip unnecessary stop/restart.

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