grover / homebridge-dacp

Remotely control Apple TV and iTunes via HomeKit.
MIT License
151 stars 14 forks source link

"ECONNREFUSED" error occur frequently #8

Closed nitaybz closed 6 years ago

nitaybz commented 6 years ago

This happens a lot:

Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP] Fatal error while talking to Living Room Apple TV:
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP]
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP]   Error: {"error":{"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"10.0.0.xx","port":3689},"options":{"encoding":null,"url":"http://Living-Room.local.:3689/ctrl-int/1/getproperty","qs":{"properties":"dacp.playingtime","session-id":1},"headers":{"Viewer-Only-Client":"1"}}}
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP]
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP] Attempting to reconnect to Living Room Apple TV in 0.1 seconds.
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP] Failed to retrieve the current playback position. Stopping continuous updates. Error: [object Object]
Dec 26 19:49:04 raspberrypi homebridge[1026]: [2017-12-26 19:49:04] [DACP] [Living Room Apple TV] Retrieving updates from DACP server failed with error [object Object]
Dec 26 19:49:05 raspberrypi homebridge[1026]: [2017-12-26 19:49:05] [DACP] Connecting to Living-Room.local.:3689 for Living Room Apple TV
Dec 26 19:49:05 raspberrypi homebridge[1026]: [2017-12-26 19:49:05] [DACP] Connected to Living Room with session ID 1
Dec 26 19:49:06 raspberrypi homebridge[1026]: [2017-12-26 19:49:06] [DACP] The accessory Living Room Apple TV is down.
Dec 26 19:49:07 raspberrypi homebridge[1026]: [2017-12-26 19:49:07] [DACP] The accessory Living Room Apple TV is announced.
Dec 26 19:49:07 raspberrypi homebridge[1026]: [2017-12-26 19:49:07] [DACP] Attempting to reconnect to Living Room Apple TV in 0.1 seconds.
Dec 26 19:49:07 raspberrypi homebridge[1026]: [2017-12-26 19:49:07] [DACP] Connecting to Living-Room.local.:3689 for Living Room Apple TV
Dec 26 19:49:07 raspberrypi homebridge[1026]: [2017-12-26 19:49:07] [DACP] Connected to Living Room with session ID 2
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] Fatal error while talking to Living Room Apple TV:
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP]
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP]   Error: {"error":{"code":"ECONNRESET"},"options":{"encoding":null,"url":"http://Living-Room.local.:3689/ctrl-int/1/playstatusupdate","qs":{"revision-number":3,"session-id":1},"headers":{"Viewer-Only-Client":"1"}}}
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP]
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] Attempting to reconnect to Living Room Apple TV in 0.1 seconds.
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] [Living Room Apple TV] Retrieving updates from DACP server failed with error [object Object]
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] [Living Room Apple TV] Retrieving updates from DACP server failed with error [object Object]
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] Connecting to Living-Room.local.:3689 for Living Room Apple TV
Dec 26 20:13:00 raspberrypi homebridge[1026]: [2017-12-26 20:13:00] [DACP] Connected to Living Room with session ID 1
Dec 26 20:13:01 raspberrypi homebridge[1026]: [2017-12-26 20:13:01] [DACP] The accessory Living Room Apple TV is down.
Dec 26 20:13:02 raspberrypi homebridge[1026]: [2017-12-26 20:13:02] [DACP] The accessory Living Room Apple TV is announced.
Dec 26 20:13:02 raspberrypi homebridge[1026]: [2017-12-26 20:13:02] [DACP] Attempting to reconnect to Living Room Apple TV in 0.1 seconds.
Dec 26 20:13:02 raspberrypi homebridge[1026]: [2017-12-26 20:13:02] [DACP] Connecting to Living-Room.local.:3689 for Living Room Apple TV
Dec 26 20:13:03 raspberrypi homebridge[1026]: [2017-12-26 20:13:03] [DACP] Connected to Living Room with session ID 2
grover commented 6 years ago

Hi nitaybz,

I've seen that happen on mine too. Unfortunately I can't yet figure out the specific cause for this. Sometimes the Apple TV responds with something that the code doesn't expect - so the connection is dropped and reestablished - hence the ECONNRESET/ECONNREFUSED.

In other cases this does happen out of the blue. I'll try to add more logging to figure out the cause for this.

nitaybz commented 6 years ago

I can't tell if it's related cause I haven't noticed the exact time but sometimes the automations I'm using with this switch are not working... when I tried to see what's going on in home app, I saw the switch was ON, but when I paused and play it didn't show immediately on Home app, only after I was out of the app and back in so it would update. normally it works fine and I can see it pushes the new status to home app without the need of updating... just FYI while you're digging in logs...

grover commented 6 years ago

Hey @nitaybz, I finally got around to take a look into this. I think I've got a solution, but it would be great if you could give me some feedback before I publish the fix.

Could you please install the following plugin version? (You might need root/sudo privileges.)

npm install -g github:grover/homebridge-dacp#76a5e45b012006068090bdfbe58c1d80256c8876

And report back to me? I haven't seen the errors again, but I'd like to hear from you too. Should the above version cause any errors, you can always revert back by installing the latest version in the npm repository:

npm install -g homebridge-dacp@latest

Thanks!

grover commented 6 years ago

Another update with some more small fixes:

npm install -g github:grover/homebridge-dacp#16131f6158055c9b0aec9b6ea17fe5b3a307f7e3

Any news from you?

nitaybz commented 6 years ago

sorry I had a busy week... I'm installing now, will let you know if there are any issues

nitaybz commented 6 years ago

so far so good... closing the issue! thanks a lot!