Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using amazon.ca, the HTTPPush connection incorrectly defaults to bob-dispatch-prod-eu.amazon.com #204

Open
danielbrunt57 opened this issue Oct 19, 2024 · 3 comments

Comments

@danielbrunt57
Copy link

I am new to node-red-contrib-alexa-remote2 as of yesterday but have been a long time user of the Alexa Media Player in HA and have been doing lots of debugging in it and alexapy which proved invaluable in figuring out what to set the "Push Dispatch Host" to despite the severe lack of user documentation on what that entry can be set to.
My Echo devices are registered to my account in amazon.ca but that domain resulted in HTTP2 connecting by default to bob-dispatch-prod-eu.amazon.com. When I used amazon.com then HTTP2Push connected to the correct gateway (bob-dispatch-prod-na.amazon.com) but then I had zero devices. Before I delved inside the code, I tried entering the alexapy gateway alexa.na.gateway.devices.a2z.com and Push then worked. That alias is the same IP as the bob-dispatch-prod-na.amazon.com alias.

I therefore recommend that the /alexa-remote2/alexa-http2push.js should be amended as follows for amazon.ca:

    connect() {
        this.inClosing = false;
        this.update_access_token(token => {
            this.access_token = token;

            let host = 'bob-dispatch-prod-eu.amazon.com';
            if (this._options.pushDispatchHost) {
                host = this._options.pushDispatchHost;
            } else if (this._options.amazonPage === 'amazon.com') {
                host = 'bob-dispatch-prod-na.amazon.com';
            } else if (this._options.amazonPage === 'amazon.ca') {
                host = 'bob-dispatch-prod-na.amazon.com';
            } else if (this._options.amazonPage === 'amazon.com.br') {
                host = 'bob-dispatch-prod-na.amazon.com';
            } else if (this._options.amazonPage === 'amazon.co.jp') {
                host = 'bob-dispatch-prod-fe.amazon.com';
            } else if (this._options.amazonPage === 'amazon.com.au') {
                host = 'bob-dispatch-prod-fe.amazon.com';
            }
            this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Use host ${host}`);

I'd also recommend that the Alexa Account configuration node help info include the Push Dispatch Host field and the three possible settings for that field: bob-dispatch-prod-eu.amazon.com, bob-dispatch-prod-na.amazon.com' and 'bob-dispatch-prod-fe.amazon.com.

@bbindreiter
Copy link
Owner

Hi @danielbrunt57, thank you very much for your input! This part of the code sits here: https://github.com/Apollon77/alexa-remote

The maintainer @Apollon77 would surely appreciate a PR.

@danielbrunt57
Copy link
Author

danielbrunt57 commented Oct 19, 2024

As per alexapy/const.py, see PR 246 for 4 additional domain lookups:
'amazon.ca','amazon.com.mx': host 'bob-dispatch-prod-na.amazon.com'
'amazon.com.in','amazon.co.nz': host 'bob-dispatch-prod-fe.amazon.com'

@Apollon77
Copy link

released in 7.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants