Problème brain et spotify après passage en HTTPS


#1

Bonjour, je vous demande de l’aide car j’aide multiple problème après avoir passé gladys en https…
Tout d’abord, le plus important : le brain.
Quand je dis quelque chose a gladys (ça peut être n’importe quoi), je trouve une erreur dans la console.

 Hi !
1|gladys-v | Received sentence : comment vas-tu
1|gladys-v | Error: Invalid URI "https:///brain/classify?token=c49be6d21749537df33214d09ac81dd3bc2a77dc&q=comment%20vas-tu". This can be caused by a crappy redirection.
1|gladys-v |     at Request.init (/home/pi/gladys-voice/node_modules/request/request.js:273:31)
1|gladys-v |     at Redirect.onResponse (/home/pi/gladys-voice/node_modules/request/lib/redirect.js:149:11)
1|gladys-v |     at Request.onRequestResponse (/home/pi/gladys-voice/node_modules/request/request.js:993:22)
1|gladys-v |     at emitOne (events.js:116:13)
1|gladys-v |     at ClientRequest.emit (events.js:211:7)
1|gladys-v |     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:551:21)
1|gladys-v |     at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
1|gladys-v |     at Socket.socketOnData (_http_client.js:440:20)
1|gladys-v |     at emitOne (events.js:116:13)
1|gladys-v |     at Socket.emit (events.js:211:7)

alors je comprends bien qu’il y a un problème avec les requette en https, mais je sais pas comment résoudre le problème…

2eme problème : spotify.
J’ai donc suivi à la lettre les indications sur la page du module spotify et je l’ai installé. Pourtant, quand je lance le script qui joue un album ( gladys.music.playPlaylist('spotify:album:4ydl8Ci7OsndhI2ALnrpIv)
j’ai une erreur que je ne comprends pas…

0|gladys   | gladys.utils.sqlUnique was not able to find element
0|gladys   | Query = "
0|gladys   |             SELECT dt.id, dt.type, dt.unit, dt.min, dt.max, d.identifier, dt.device, d.service, d.machine, dt.identifier as deviceTypeIdentifier
0|gladys   |             FROM devicetype dt
0|gladys   |             JOIN device d ON d.id = dt.device
0|gladys   |             WHERE dt.type = 'music'
0|gladys   |             LIMIT 1;
0|gladys   |     "
0|gladys   | Params = "[]"
0|gladys   | Unhandled rejection Error: NotFound
0|gladys   |     at /home/pi/gladys/api/core/utils/utils.sqlUnique.js:11:31
0|gladys   |     at tryCatcher (/home/pi/gladys/node_modules/bluebird/js/release/util.js:16:23)
0|gladys   |     at Promise._settlePromiseFromHandler (/home/pi/gladys/node_modules/bluebird/js/release/promise.js:512:31)
0|gladys   |     at Promise._settlePromise (/home/pi/gladys/node_modules/bluebird/js/release/promise.js:569:18)
0|gladys   |     at Promise._settlePromise0 (/home/pi/gladys/node_modules/bluebird/js/release/promise.js:614:10)
0|gladys   |     at Promise._settlePromises (/home/pi/gladys/node_modules/bluebird/js/release/promise.js:693:18)
0|gladys   |     at Promise._fulfill (/home/pi/gladys/node_modules/bluebird/js/release/promise.js:638:18)
0|gladys   |     at /home/pi/gladys/node_modules/bluebird/js/release/nodeback.js:42:21
0|gladys   |     at /home/pi/gladys/node_modules/sails-mysql/lib/connections/spawn.js:120:16
0|gladys   |     at Object.poolfully [as releaseConnection] (/home/pi/gladys/node_modules/sails-mysql/lib/connections/release.js:28:12)
0|gladys   |     at Query._callback (/home/pi/gladys/node_modules/sails-mysql/lib/connections/spawn.js:105:35)
0|gladys   |     at Query.Sequence.end (/home/pi/gladys/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
0|gladys   |     at Query._handleFinalResultPacket (/home/pi/gladys/node_modules/mysql/lib/protocol/sequences/Query.js:144:8)
0|gladys   |     at Query.EofPacket (/home/pi/gladys/node_modules/mysql/lib/protocol/sequences/Query.js:128:8)
0|gladys   |     at Protocol._parsePacket (/home/pi/gladys/node_modules/mysql/lib/protocol/Protocol.js:280:23)
0|gladys   |     at Parser.write (/home/pi/gladys/node_modules/mysql/lib/protocol/Parser.js:73:12)
0|gladys   |     at Protocol.write (/home/pi/gladys/node_modules/mysql/lib/protocol/Protocol.js:39:16)
0|gladys   |     at Socket.<anonymous> (/home/pi/gladys/node_modules/mysql/lib/Connection.js:96:28)
0|gladys   |     at emitOne (events.js:116:13)
0|gladys   |     at Socket.emit (events.js:211:7)
0|gladys   |     at addChunk (_stream_readable.js:263:12)
0|gladys   |     at readableAddChunk (_stream_readable.js:250:11)

enfin si, au début je pense que le problème vien des DB sql, mais encore une fois, je suis très novice en programmation, et je ne sais comment résoudre mon problème…
Si quelqu’un se sens de m’aider…


#2

Pour Gladys-voice, il faut que tu indique l’URL directe du serveur Gladys via le port 8080 dans le fichier config.js, exemple:

gladysUrl: process.env.GLADYS_URL || ‘http://IP_DE_TON_RASPBERRY_PI:8080’,

As tu redémarré Gladys? J’ai l’impression que l’init du module ne passe pas…

Tu peux regarder limite dans les logs du démarrage si quelque chose de spécial est affiché concernant le module spotify?


#3

Ok, alors pour le reco vocal, c’est good (j’aurai du y penser ça parait évident maintenant…)
Pour spotify j’ai reboot gladys, voici mes logs de demarrage (elles ne concernent pas que spotify, mais je les met car je trouve qu’il y a beaucoup d’erreur…)

/home/pi/.pm2/logs/gladys-voice-error-1.log last 100 lines:
1|gladys-v | (node:22444) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:1073) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:1099) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:1131) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:964) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:980) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:964) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:970) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:976) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:940) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | Auth error:Error: invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.
1|gladys-v | (node:930) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:976) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:934) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:927) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:978) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:983) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:1031) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:932) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:986) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:948) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
1|gladys-v | (node:982) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead

/home/pi/.pm2/logs/gladys-error-0.log last 100 lines:
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 324.231 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 267.265 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 115.633 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 70.264 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 68.446 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 237.679 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 188.184 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 111.198 ms
0|gladys   | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|gladys   | WebapiError: Not Found
0|gladys   | Unhandled rejection WebapiError: Not Found
0|gladys   | Unhandled rejection WebapiError: Not Found
0|gladys   | Unhandled rejection WebapiError: Not Found
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   |
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   | WARNING: You currently have your default CORS settings configured to allow
0|gladys   | all requests from all origins, with credentials.  This may leave your app
0|gladys   | open to attack by third-party sites!  Consider making your `origins` setting
0|gladys   | more restrictive or setting `credentials` to false, or else make certain that
0|gladys   | none of your routes perform sensitive actions or reveal secure information.
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   |
0|gladys   | -------------------------------------------------------
0|gladys   | :: Sat Mar 23 2019 12:14:47 GMT+0000 (UTC)
0|gladys   | Environment : production
0|gladys   | Port        : 8080
0|gladys   | -------------------------------------------------------
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 909.394 ms
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   |
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   | WARNING: You currently have your default CORS settings configured to allow
0|gladys   | all requests from all origins, with credentials.  This may leave your app
0|gladys   | open to attack by third-party sites!  Consider making your `origins` setting
0|gladys   | more restrictive or setting `credentials` to false, or else make certain that
0|gladys   | none of your routes perform sensitive actions or reveal secure information.
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   |
0|gladys   | -------------------------------------------------------
0|gladys   | :: Sat Mar 23 2019 12:17:52 GMT+0000 (UTC)
0|gladys   | Environment : production
0|gladys   | Port        : 8080
0|gladys   | -------------------------------------------------------
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 341.104 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 167.018 ms
0|gladys   | Getting conversation undefined, found 0 messages.
0|gladys   | Brain : answer : Found 2 possible.
0|gladys   | brain : classify : Answered in 0s, 150.866 ms
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   | Warning: connect.session() MemoryStore is not
0|gladys   | designed for a production environment, as it will leak
0|gladys   | memory, and will not scale past a single process.
0|gladys   |
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   | WARNING: You currently have your default CORS settings configured to allow
0|gladys   | all requests from all origins, with credentials.  This may leave your app
0|gladys   | open to attack by third-party sites!  Consider making your `origins` setting
0|gladys   | more restrictive or setting `credentials` to false, or else make certain that
0|gladys   | none of your routes perform sensitive actions or reveal secure information.
0|gladys   | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
0|gladys   |
0|gladys   | -------------------------------------------------------
0|gladys   | :: Sat Mar 23 2019 12:21:07 GMT+0000 (UTC)
0|gladys   | Environment : production
0|gladys   | Port        : 8080
0|gladys   | -------------------------------------------------------

/home/pi/.pm2/logs/gladys-out-0.log last 100 lines:
0|gladys   |
0|gladys   |    Sails              <|    .-..-.
0|gladys   |    v0.12.14            |\
0|gladys   |                       /|.\
0|gladys   |                      / || \
0|gladys   |                    ,'  |'  \
0|gladys   |                 .-'.-==|/_--'
0|gladys   |                 `--'-------'
0|gladys   |    __---___--___---___--___---___--___
0|gladys   |  ____---___--___---___--___---___--___-__
0|gladys   |
0|gladys   | Server lifted in `/home/pi/gladys`
0|gladys   | To see your app, visit http://localhost:8080
0|gladys   | To shut down Sails, press <CTRL> + C at any time.
0|gladys   |
0|gladys   |
0|gladys   | Gladys Gateway: Not connected.
0|gladys   | Gladys is up to date !
0|gladys   | The Spotify token was successful refresh!
0|gladys   | Event : create : new Event with code : gladys-launched
0|gladys   | Scenario : Trigger : New event : gladys-launched
0|gladys   | Scenario : Trigger : Found 0 launchers with code gladys-launched.
0|gladys   | Access with token to user Guillaume
0|gladys   | brain : classify : Identified label brain;no-command-detected
0|gladys   | Brain : answer : Answering with label no-command-detected in language fr-FR
0|gladys   | Brain : answer : Trying to contact socket
0|gladys   | Unable to reach user with service socket. Trying with other services.
0|gladys   | Brain : answer : Trying to contact speak
0|gladys   | Using cache, file already exist
0|gladys   | Message sent with success with speak.
0|gladys   | Sentence : create : Inserting sentence ceci est le début de l'année
0|gladys   | Access with token to user Guillaume
0|gladys   | brain : classify : Identified label brain;no-command-detected
0|gladys   | Brain : answer : Answering with label no-command-detected in language fr-FR
0|gladys   | Brain : answer : Trying to contact socket
0|gladys   | Unable to reach user with service socket. Trying with other services.
0|gladys   | Brain : answer : Trying to contact speak
0|gladys   | Using cache, file already exist
0|gladys   | Message sent with success with speak.
0|gladys   | Sentence : create : Inserting sentence ceci
0|gladys   | Access with token to user Guillaume
0|gladys   | brain : classify : Identified label brain;no-command-detected
0|gladys   | Brain : answer : Answering with label no-command-detected in language fr-FR
0|gladys   | Brain : answer : Trying to contact socket
0|gladys   | Unable to reach user with service socket. Trying with other services.
0|gladys   | Brain : answer : Trying to contact speak
0|gladys   | Using cache, file already exist
0|gladys   | Message sent with success with speak.
0|gladys   | Sentence : create : Inserting sentence ceci est le début des log
0|gladys   | Socket disconnected, but session could not be loaded to pass to configured disconnect handler: `sails.config.sockets.afterDisconnect()`.  Will pass a fake, empty session as argument to lifecycle callback.  Details:
0|gladys   |  Error: Could not parse session id from cookie of connecting socket, and then failed again when trying to use a generated cookie. Something has probably gone wrong with your session store configuration.
0|gladys   |     at _createError (/home/pi/gladys/node_modules/sails-hook-sockets/lib/load-session-from-socket.js:44:17)
0|gladys   |     at loadSessionFromSocket (/home/pi/gladys/node_modules/sails-hook-sockets/lib/load-session-from-socket.js:47:7)
0|gladys   |     at Socket.onSocketDisconnect (/home/pi/gladys/node_modules/sails-hook-sockets/lib/on-connect.js:43:7)
0|gladys   |     at emitOne (events.js:116:13)
0|gladys   |     at Socket.emit (events.js:211:7)
0|gladys   |     at Socket.emit (/home/pi/gladys/node_modules/socket.io/lib/socket.js:141:10)
0|gladys   |     at Socket.onclose (/home/pi/gladys/node_modules/socket.io/lib/socket.js:441:8)
0|gladys   |     at Server.close (/home/pi/gladys/node_modules/socket.io/lib/index.js:402:34)
0|gladys   |     at shutdownHTTP (/home/pi/gladys/node_modules/sails/lib/app/lower.js:130:22)
0|gladys   |     at /home/pi/gladys/node_modules/sails/node_modules/async/lib/async.js:713:13
0|gladys   |     at Immediate.iterate (/home/pi/gladys/node_modules/sails/node_modules/async/lib/async.js:262:13)
0|gladys   |     at runCallback (timers.js:789:20)
0|gladys   |     at tryOnImmediate (timers.js:751:5)
0|gladys   |     at processImmediate [as _immediateCallback] (timers.js:722:5)
0|gladys   | undefined
0|gladys   | Gladys version : 3.12.1
0|gladys   | Gladys Gateway: Init Procedure : Getting keys from database
0|gladys   | Bootstrap is taking unusually long to execute its callback (2000 milliseconds).
0|gladys   | Perhaps you forgot to call it?  The callback is the first argument of the function, `cb`.
0|gladys   | Gladys brain loaded with success !
0|gladys   | Gladys database schema/data is up to date. No migration required. ( DB = 3.12.1 )
0|gladys   | Successfully checked DB version.
0|gladys   | Scheduled sunrise to 2019-3-23 05:36:14.
0|gladys   | Scheduled alarm ik, with id 8
0|gladys   | Scheduled sunset to 2019-3-23 17:52:00.
0|gladys   |
0|gladys   |                .-..-.
0|gladys   |
0|gladys   |    Sails              <|    .-..-.
0|gladys   |    v0.12.14            |\
0|gladys   |                       /|.\
0|gladys   |                      / || \
0|gladys   |                    ,'  |'  \
0|gladys   |                 .-'.-==|/_--'
0|gladys   |                 `--'-------'
0|gladys   |    __---___--___---___--___---___--___
0|gladys   |  ____---___--___---___--___---___--___-__
0|gladys   |
0|gladys   | Server lifted in `/home/pi/gladys`
0|gladys   | To see your app, visit http://localhost:8080
0|gladys   | To shut down Sails, press <CTRL> + C at any time.
0|gladys   |
0|gladys   |
0|gladys   | Gladys Gateway: Not connected.
0|gladys   | Gladys is up to date !
0|gladys   | The Spotify token was successful refresh!
0|gladys   | Event : create : new Event with code : gladys-launched
0|gladys   | Scenario : Trigger : New event : gladys-launched
0|gladys   | Scenario : Trigger : Found 0 launchers with code gladys-launched.

sinon voici ce que j’ai mis pour configurer le module spotify (au cas ou j’aurai fait une erreur)
image

sachant que le refresh token c’est mis tout seul, je savais pas si il fallait le communiquer donc je l’ai censuré… xD

sinon quand je lance la musique dans un script j’obtiens ça :


#4

Hello!

Bon j’ai suivi la pelote, le tutoriel du module spotify est tout simplement faux!

Fais plutôt dans un script:

gladys.modules['spotify-connect'].music.playPlaylist('spotify:album:4ydl8Ci7OsndhI2ALnrpIv');

ça devrait mieux marcher!


#5

Salut, perso quand j’exécute ce que tu m’a donné j’ai ça : (et pas de musique ce serait trop beau…)
0|gladys | (node:831) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 10): WebapiError: Not Found
On est bien d’accord que l’url de redirection (je suis en https) c’est : https://ip-gladys/spotify ?
Parce que j’ai mis la même dans les paramètres de gladys et dans ceux de spotify, c’est pas l’adresse ip publique par hasard (on sait jamais hein ^^)


#6

Ah mince :confused: Il faudrait voir avec des utilisateurs du module, personnellement je n’ai pas Spotify, je t’ai proposé cette ligne à l’instinct en lisant le code!

Oui oui, de toute façon cette URL n’intervient que lorsque tu configure Spotify, ce que tu as fais on est d’accord?

Je pense que oui, vu que tu as une variable spotify_refresh_token dans tes params…

Je te propose d’aller poser cette question sur un topic du module en question :slight_smile:


#7

Salut, oui je l’ai configuré. Merci quand même, je vais up le topic du module ^^