lukasroegner / homebridge-apple-tv-remote

Plugin for controlling Apple TVs in homebridge.
MIT License
131 stars 13 forks source link

Port already in use error when homebridge restarted #10

Closed gtg465x closed 4 years ago

gtg465x commented 4 years ago

Homebridge just failed to restart for me and it looks like it's due to the API port already being in use. I'm guessing Homebridge may have crashed for some unrelated reason and maybe this plugin couldn't release its port? Not sure what, if anything, can be done in that case, but thought I would report just in case.

[Hoomebridge] [2/19/2020, 10:10:51 PM] [AppleTvPlatform] Scanning for AppleTVs completed. 2 device(s) found.
[Homebridge] [2/19/2020, 10:10:51 PM] [AppleTvPlatform] AppleTV with unique ID X (bedroom-apple-tv) found. Connecting...
[Homebridge] [2/19/2020, 10:10:51 PM] [AppleTvPlatform] AppleTV with unique ID X (living-room-apple-tv) found. Connecting...
[Homebridge] [2/19/2020, 10:10:52 PM] [AppleTvPlatform] Connected to AppleTV with unique ID X (bedroom-apple-tv)
[Homebridge] [2/19/2020, 10:10:52 PM] [AppleTvPlatform] Connected to AppleTV with unique ID X (living-room-apple-tv)
[Homebridge] [2/19/2020, 10:10:52 PM] [AppleTvPlatform] API started.
[Homebridge] [2/19/2020, 10:10:52 PM] Error: listen EADDRINUSE: address already in use 0.0.0.0:40304
    at Server.setupListenHandle [as _listen2] (net.js:1279:14)
    at listenInCluster (net.js:1327:12)
    at doListen (net.js:1460:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)
lukasroegner commented 4 years ago

@gtg465x You can change the port of the API in the configuration if the default one is already in use.

gtg465x commented 4 years ago

@lukasroegner Yeah, I know. I have it configured for that port and this plugin is the only thing that should be using it. My problem is that sometimes the plugin doesn’t seem to release it properly. It will be working fine, and then homebridge will crash, and when it attempts to start again I sometimes, but not always, get this error.

lukasroegner commented 4 years ago

I see, it is related to #9. I have to work on a reconnecting mechanism so that the plugin gets more stable.

lukasroegner commented 4 years ago

Should be resolved with the latest release. Feel free to reopen if it still persists.