alexa-remote2
Advanced tools
Comparing version 7.0.2 to 7.0.3
@@ -48,3 +48,3 @@ const http2 = require('http2'); | ||
const http2_options = { | ||
const http2Options = { | ||
':method': 'GET', | ||
@@ -78,3 +78,3 @@ ':path': '/v20160207/directives', | ||
this.connectionActive = false; | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Close: ' + code + ': ' + reason); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Close: ${code}: ${reason}`); | ||
if (this.initTimeout) { | ||
@@ -92,13 +92,19 @@ clearTimeout(this.initTimeout); | ||
} | ||
if (this.stop) return; | ||
if (this.stop) { | ||
return; | ||
} | ||
if (this.errorRetryCounter > 100) { | ||
this.emit('disconnect', false, 'Too many failed retries. Check cookie and data'); | ||
return; | ||
} else { | ||
this.errorRetryCounter++; | ||
} | ||
this.errorRetryCounter++; | ||
const retryDelay = (immediateReconnect || this.errorRetryCounter === 1) ? 1 : Math.min(60, this.errorRetryCounter * 5); | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Retry Connection in ' + retryDelay + 's'); | ||
this.emit('disconnect', true, `Retry Connection in ${retryDelay}s (${code}: ${reason})`); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Retry Connection in ${retryDelay}s`); | ||
if (code !== undefined || reason !== undefined) { | ||
this.emit('disconnect', true, `Retry Connection in ${retryDelay}s (${code}: ${reason})`); | ||
} else { | ||
this.emit('disconnect', true, `Retry Connection in ${retryDelay}s`); | ||
} | ||
this.reconnectTimeout && clearTimeout(this.reconnectTimeout); | ||
@@ -129,8 +135,10 @@ this.reconnectTimeout = setTimeout(() => { | ||
try { | ||
this.client = http2.connect(`https://${http2_options[':authority']}`, () => { | ||
if (!this.client) return; | ||
this.client = http2.connect(`https://${http2Options[':authority']}`, () => { | ||
if (!this.client) { | ||
return; | ||
} | ||
try { | ||
this.stream = this.client.request(http2_options); | ||
this.stream = this.client.request(http2Options); | ||
} catch (error) { | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Error on Request ' + error.message); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Error on Request ${error.message}`); | ||
this.emit('error', error); | ||
@@ -149,4 +157,3 @@ return; | ||
}); | ||
} | ||
else if (headers[':status'] !== 200) { | ||
} else if (headers[':status'] !== 200) { | ||
onHttp2Close(headers[':status']); | ||
@@ -167,9 +174,11 @@ } | ||
this.pingPongInterval = setInterval(() => { | ||
if (!this.stream || !this.client) return; | ||
if (!this.stream || !this.client) { | ||
return; | ||
} | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Send Ping'); | ||
//console.log('SEND: ' + msg.toString('hex')); | ||
// console.log('SEND: ' + msg.toString('hex')); | ||
try { | ||
this.client.ping(() => onPingResponse(true)); | ||
} catch (error) { | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Error on Ping ' + error.message); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Error on Ping ${error.message}`); | ||
} | ||
@@ -211,7 +220,7 @@ | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Command ' + command + ': ' + JSON.stringify(payload, null, 4)); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Command ${command}: ${JSON.stringify(payload, null, 4)}`); | ||
this.emit('command', command, payload); | ||
}); | ||
} catch (err) { | ||
this.emit('unexpected-response', `Could not parse json: ${message} : ${err.message}`); | ||
this.emit('unexpected-response', `Could not parse json: ${message}: ${err.message}`); | ||
} | ||
@@ -224,3 +233,3 @@ } | ||
this.stream.on('error', (error) => { | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Stream-Error: ' + error); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Stream-Error: ${error}`); | ||
this.emit('error', error); | ||
@@ -235,3 +244,3 @@ this.stream && this.stream.end(); | ||
this.client.on('error', (error) => { | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Client-Error: ' + error); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Client-Error: ${error}`); | ||
this.emit('error', error); | ||
@@ -243,3 +252,3 @@ this.stream && this.stream.end(); | ||
catch (err) { | ||
this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Error on Init ' + err.message); | ||
this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Error on Init ${err.message}`); | ||
this._options.logger && this._options.logger(err.stack); | ||
@@ -257,5 +266,5 @@ this.emit('error', err); | ||
} catch (err) { | ||
//just make sure | ||
// just make sure | ||
} | ||
if (this.stream || !this.reconnectTimeout) { // seems no close was emitted so far?! | ||
if (this.stream || !this.reconnectTimeout) { // it seems no close was emitted so far?! | ||
onHttp2Close(); | ||
@@ -281,3 +290,5 @@ } | ||
this.stop = true; | ||
if (!this.client && !this.stream) return; | ||
if (!this.client && !this.stream) { | ||
return; | ||
} | ||
try { | ||
@@ -287,3 +298,3 @@ this.stream && this.stream.end(); | ||
} catch (e) { | ||
this.connectionActive && this._options.logger && this._options.logger('Alexa-Remote HTTP2-PUSH: Disconnect error: ' + e.message); | ||
this.connectionActive && this._options.logger && this._options.logger(`Alexa-Remote HTTP2-PUSH: Disconnect error: ${e.message}`); | ||
} | ||
@@ -293,3 +304,2 @@ } | ||
module.exports = AlexaHttp2Push; |
{ | ||
"name": "alexa-remote2", | ||
"version": "7.0.2", | ||
"version": "7.0.3", | ||
"description": "Remote Control for amazon echo devices", | ||
@@ -35,3 +35,3 @@ "author": { | ||
"querystring": "^0.2.1", | ||
"ws": "^8.14.2", | ||
"ws": "^8.16.0", | ||
"extend": "^3.0.2", | ||
@@ -41,5 +41,5 @@ "uuid": "^9.0.1" | ||
"devDependencies": { | ||
"@alcalzone/release-script": "^3.6.0", | ||
"@alcalzone/release-script-plugin-license": "^3.5.9", | ||
"eslint": "^8.54.0" | ||
"@alcalzone/release-script": "^3.7.0", | ||
"@alcalzone/release-script-plugin-license": "^3.7.0", | ||
"eslint": "^8.56.0" | ||
}, | ||
@@ -46,0 +46,0 @@ "scripts": { |
@@ -16,7 +16,7 @@ # alexa-remote2 | ||
### Issues when getting the cookie and tokens initially | ||
If you still use the E-Mail or SMS based 2FA flow then this might not work. Please update the 2FA/OTP method in the amazon settings to the current process. | ||
If you still use the E-Mail or SMS based 2FA flow, then this might not work. Please update the 2FA/OTP method in the amazon settings to the current process. | ||
If you open the Proxy URL from a mobile device where also the Alexa App is installed on it might be that it do not work because Amazon might open the Alexa App. So please use a device or PC where the Alexa App is not installed | ||
If you open the Proxy URL from a mobile device where also the Alexa App is installed on, it might be that it does not work because Amazon might open the Alexa App. So please use a device or PC where the Alexa App is not installed | ||
If you see a page that tells you that "alexa.amazon.xx is deprecated" and you should use the alexa app and with a QR code on it when you enter the Proxy URL" then this means that you call the proxy URL ith a different IP/Domainname then you entered in the "proxy own IP" settings or you adjusted the IP shown in the Adapter configuration. The "proxy own IP" setting **needs to** match the IP/Domainname you use to call the proxy URL! | ||
If you see a page that tells you that "alexa.amazon.xx is deprecated" and you should use the alexa app and with a QR code on it when you enter the Proxy URL" then this means that you call the proxy URL ith a different IP/Domainname then you entered in the "proxy own IP" settings, or you adjusted the IP shown in the Adapter configuration. The "proxy own IP" setting **needs to** match the IP/Domainname you use to call the proxy URL! | ||
@@ -26,5 +26,5 @@ ### Push Connections do not connect | ||
If the Push connection is never established then you can try to use the following: | ||
* delete all cookie, formerRegistrationData and macDms from the settings | ||
* lokale the location of the alexa-cookie2 library in your npm tree | ||
If the Push connection is never established, then you can try to use the following: | ||
* delete all cookies, formerRegistrationData and macDms from the settings | ||
* locale the location of the alexa-cookie2 library in your npm tree | ||
* check if there is a file like .../alexa-cookie2/lib/formerDataStore.json - if existing please delete them | ||
@@ -48,2 +48,5 @@ * get new cookie via proxy | ||
## Changelog: | ||
### 7.0.3 (2024-01-25) | ||
* (Apollon77) Adjust Activity Record query to newest Amazon changes | ||
### 7.0.2 (2023-11-25) | ||
@@ -50,0 +53,0 @@ * (Apollon77) Adjust some texts |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
264325
5068
472
Updatedws@^8.16.0