thoukydides / homebridge-homeconnect

Home Connect home appliances plugin for Homebridge
https://www.thouky.co.uk
ISC License
142 stars 15 forks source link

Home Connect API Error: ERROR: Error: getaddrinfo ENOTFOUND api.home-connect.com #276

Closed tobihoby closed 7 months ago

tobihoby commented 7 months ago

Description of Issue

Home Connect API Error: ERROR: Error: getaddrinfo ENOTFOUND api.home-connect.com

Expected Behaviour

...

Steps to Reproduce

always

Plugin Version

0.41.4

Environment

Home Connect Appliance(s)

No response

HomeKit App(s)

No response

Diagnostic Checks

Log File

[22.4.2024, 15:32:59] [HomeConnect] Launched child bridge with PID 2289480
[22.4.2024, 15:33:00] Registering platform 'homebridge-homeconnect.HomeConnect'
[22.4.2024, 15:33:00] [HomeConnect] Loaded homebridge-homeconnect v0.41.4 child bridge successfully
[22.4.2024, 15:33:00] Loaded 2 cached accessories from cachedAccessories.0E2A990189F3.
[22.4.2024, 15:33:00] [HomeConnect] Restored 2 cached accessories
[22.4.2024, 15:33:00] [HomeConnect] homebridge-homeconnect version 0.41.4
[22.4.2024, 15:33:00] [HomeConnect] Node.js version 20.12.0 (satisfies >=20.0.0 || ^18.18.0)
[22.4.2024, 15:33:00] [HomeConnect] Homebridge version 1.8.0 (satisfies >=1.7.0)
[22.4.2024, 15:33:00] [HomeConnect] Homebridge API version 2.7 (satisfies ^2.7)
[22.4.2024, 15:33:00] [HomeConnect] Homebridge HAP version 0.12.0 (satisfies >=0.9.0)
[22.4.2024, 15:33:00] [HomeConnect] Attempting authorisation
[22.4.2024, 15:33:00] Homebridge v1.8.0 (HAP v0.12.0) (HomeConnect) is running on port 30305.
[22.4.2024, 15:33:00] [HomeConnect] Saved access token has expired
[22.4.2024, 15:33:00] [HomeConnect] Unable to use saved API authorisation (Home Connect API Error: ERROR: Error: getaddrinfo ENOTFOUND api.home-connect.com)
[22.4.2024, 15:33:00] [HomeConnect] Requesting authorisation using the Device Flow
[22.4.2024, 15:33:00] [HomeConnect] [API authorisation] Home Connect API Error: ERROR: Error: getaddrinfo ENOTFOUND api.home-connect.com
[22.4.2024, 15:33:00] [HomeConnect] POST /security/oauth/device_authorization
[22.4.2024, 15:33:00] [HomeConnect]                     └─ Error: getaddrinfo ENOTFOUND api.home-connect.com
[22.4.2024, 15:33:00] [HomeConnect] Authorisation attempt abandoned; restart Homebridge to try again

Configuration

"483100539472002293": {
        "addprograms": "none",
        "names": {
            "prefix": {
                "other": true,
                "programs": false
            }
        },
        "programs": [],
        "features": {
            "Door": true,
            "Event Buttons": true
        },
        "enabled": true
    },
    "clientid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "language": {
        "api": "de-DE"
    },
    "_bridge": {
        "port": 30305,
        "username": "0E:2A:99:01:89:F3"
    },
    "simulator": false,
    "platform": "HomeConnect",
    "463100536427004113": {
        "addprograms": "none",
        "names": {
            "prefix": {
                "other": true,
                "programs": false
            }
        },
        "programs": [],
        "features": {
            "Door": true,
            "Event Buttons": true
        },
        "enabled": true
    },
    "name": "HomeConnect"
}

Additional Information

No response

thoukydides commented 7 months ago

The ENOTFOUND error is a DNS resolution failure for api.home-connect.com.

I am not seeing that problem myself. I have tried with the same node, homebridge, and homebridge-homeconnect, versions (but on Ubuntu 22.04.4 LTS instead of Debian). Hence, I suspect that the problem is with your own setup or internet connection. Alternatively, it might have been due to a temporary problem that has been rectified.

This plugin isn't even performing the DNS resolution itself - it is just passing the hostname as part of the URL as the first parameter to undici's new Client method. If this is actually a bug (which I don't think it is) then it is likely to be in undici.

From the log you provided it is clear that this plugin installation was working previously. It has a previously saved OAuth token, and is restoring accessories for two appliances, neither of which would be the case if it has not been successfully authorised. You have also raised previous issues (#170 and #228) that demonstrated working installations.

Have you changed anything since it was last working? For example applied any Debian updates, changed your configuration, updated this plugin, etc?

Can you still reproduce the same failure?

What do you get if you try dig api.home-connect.com or nslookup api.home-connect.com from a shell prompt on the same system?

With my local DNS I get:

> dig api.home-connect.com

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> api.home-connect.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51479
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 45ecf977c5f84dea0100000066266ff63a75641a1749eef6 (good)
;; QUESTION SECTION:
;api.home-connect.com.          IN      A

;; ANSWER SECTION:
api.home-connect.com.   129     IN      CNAME   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com.
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 9 IN A 52.59.7.53
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 9 IN A 18.158.166.82
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 9 IN A 3.77.174.102

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Mon Apr 22 15:11:02 BST 2024
;; MSG SIZE  rcvd: 194

> nslookup api.home-connect.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
api.home-connect.com    canonical name = api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com.
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 18.158.166.82
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 3.77.174.102
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 52.59.7.53

I receive the same answers if I force use of Google's DNS:

> dig @8.8.8.8 api.home-connect.com

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @8.8.8.8 api.home-connect.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6423
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;api.home-connect.com.          IN      A

;; ANSWER SECTION:
api.home-connect.com.   75      IN      CNAME   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com.
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 14 IN A 18.158.166.82
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 14 IN A 3.77.174.102
api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com. 14 IN A 52.59.7.53

;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
;; WHEN: Mon Apr 22 15:27:25 BST 2024
;; MSG SIZE  rcvd: 163

> nslookup api.home-connect.com 8.8.8.8
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
api.home-connect.com    canonical name = api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com.
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 18.158.166.82
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 3.77.174.102
Name:   api-gateway-lb-414308807.eu-central-1.elb.amazonaws.com
Address: 52.59.7.53
tobihoby commented 7 months ago

Thank you very much, that was actually it...

I provided the RaspberryPi with the router's IP via DHCP, including for DNS. Nothing was changed.

I've now entered the DNS manually and it's working again. Very funny.

Thanks!