Skip to content

Commit

Permalink
* (Apollon77) Adjust automatic Cookie Refresh interval from 7 to 4 days
Browse files Browse the repository at this point in the history
* (Apollon77) Add other checks for websocket connection handling (Sentry IOBROKER-ALEXA2-32)
  • Loading branch information
Apollon77 committed Apr 18, 2021
1 parent 01f3b24 commit ab907b5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 43 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Thank you for that work.

## Changelog:

### __WORK IN PROGRESS__
* (Apollon77) Adjust automatic Cookie Refresh interval from 7 to 4 days
* (Apollon77) Add other checks for websocket connection handling (Sentry IOBROKER-ALEXA2-32)

### 3.7.1 (2021-02-03)
* (Apollon77) also capture tests from ASR_REPLACEMENT_TEXT and TTS_REPLACEMENT_TEXT into summary and alexaResponse

Expand Down
2 changes: 1 addition & 1 deletion alexa-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AlexaRemote extends EventEmitter {
delete this._options.refreshCookieInterval;
}
if (this._options.cookieRefreshInterval !== 0) {
this._options.cookieRefreshInterval = this._options.cookieRefreshInterval || 7*24*60*60*1000; // Auto Refresh after 7 days
this._options.cookieRefreshInterval = this._options.cookieRefreshInterval || 4 * 24 * 60 * 60 * 1000; // Auto Refresh after 4 days
}

const self = this;
Expand Down
5 changes: 3 additions & 2 deletions alexa-wsmqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@ class AlexaWsMqtt extends EventEmitter {
}, 30000);

this.websocket.on('open', () => {
if (! this.websocket) return;
if (this.stop) {
this.websocket.close();
return;
}
if (! this.websocket) return;
this._options.logger && this._options.logger('Alexa-Remote WS-MQTT: Open: ' + url);
this.connectionActive = false;

// tell Tuning Service that we support "A:H" protocol = AlphaPrococol
const msg = Buffer.from('0x99d4f71a 0x0000001d A:HTUNE');
//console.log('SEND: ' + msg.toString('ascii'));
this._options.logger && this._options.logger('Alexa-Remote WS-MQTT: Initialization Msg 1 sent');
if (this.websocket.readyState !== 1 /* OPEN */) return;
this.websocket.send(msg);
});

Expand All @@ -147,7 +148,7 @@ class AlexaWsMqtt extends EventEmitter {
});

this.websocket.on('message', (data) => {
if (!this.websocket) return;
if (!this.websocket || this.websocket.readyState !== 1 /* OPEN */) return;
let message = this.parseIncomingMessage(data);
if (msgCounter === 0) { // initialization
if (message.content.protocolName) {
Expand Down
76 changes: 38 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"layla.amazon.de"
],
"dependencies": {
"alexa-cookie2": "^3.4.2",
"alexa-cookie2": "^3.4.3",
"https": "^1.0.0",
"querystring": "^0.2.1",
"ws": "^7.4.4",
"ws": "^7.4.5",
"extend": "^3.0.2",
"uuid": "^8.3.2"
},
Expand Down

0 comments on commit ab907b5

Please sign in to comment.