pparedes1 / alexa-lgtv-remote

Control your webOS powered LG TV with amazon's alexa.
MIT License
6 stars 1 forks source link

Help on Heroku Part 2 #9

Closed StarfighterJ closed 6 years ago

StarfighterJ commented 6 years ago

Used the new Heroku Branch Code It went up there nicely but still not working; Here is screen shots of results This one is on Config Variables: just want to make sure a = sign goes in front of each value?

2018-05-14_li This one is on npm install 2018-05-14 1 This one is on npm run start

2018-05-14 2 This one is on rest of npm run start 2018-05-14 3

This one is on DIR and ls -1 2018-05-14 4

This one is on gulp 2018-05-14 5

pparedes1 commented 6 years ago

definitely do not put '=' in front of your variable value. You also need to add another environment variable for CALLHOME. I would not run npm install in your console for your app, if it doesn't work, you should start over by pushing the directory back into heroku. Also every time you set your environment variable, heroku will restart the app, and you can see that in your logs.

StarfighterJ commented 6 years ago

So I don't put the = sign in TV Socket or TV MAC or CALLHOME , but do I put the YARN PROUDCTION = false. or no?

pparedes1 commented 6 years ago

Never put equals in the variable configs, when you set variables in the dashboard, it implies that you are setting that variable equal to the value in the value field. BTW if you are using the Heroku branch you won't need to set YARN PRODUCTION, only if you are using the master branch.

StarfighterJ commented 6 years ago

Yay Finally got Heroku to work with Alexa Development test: I still try to figure out what you change in there.

pparedes1 commented 6 years ago

Congrats. The only file that changed was the package.json, and me adding a few default environment variables that I noticed if not set would blow up the code within Heroku (I might add to a future commit to the master branch). I'll delete the Heroku branch in about a week as it's redundant with the master branch but you can obviously keep using whatever you need.

Good luck with your future development of the code. It took me a while to understand all the pieces, you can play around and make suggestions and adjustments as you see fit.

StarfighterJ commented 6 years ago

Woke up today to do more Testing in Alexa development tried mute keeps say device is switched off what is going on I thought in Heroku it keep running forever. What should I do?

pparedes1 commented 6 years ago

did you check the logs of your Heroku app to see if it is still running? If you've set the CALL_HOME variable in your dashboard, it should ping that website every 15 mins and keep the application running in Heroku.

NOW, just because your application is running, doesn't mean that the TV is accessible, as the IP address is released after the tv is turned off (maybe 30 mins or so?). If you turn on TV, the application should eventually connect to it.

StarfighterJ commented 6 years ago

Check This out got ZZZ it says app is a sleep on the Icon, how do I wake it up? and Look at the var build on MAC it got a red - sign on it 2018-05-15

StarfighterJ commented 6 years ago

Got it running again but look at log,listing port

2018-05-16T00:07:26.716631+00:00 app[web.1]: [00:07:26] Using gulpfile ~/gulpfile.js 2018-05-16T00:07:26.721591+00:00 app[web.1]: [00:07:26] Starting 'lint'... 2018-05-16T00:07:26.718590+00:00 app[web.1]: [00:07:26] Starting 'build'... 2018-05-16T00:07:43.008152+00:00 app[web.1]: [00:07:43] Finished 'lint' after 16 s 2018-05-16T00:07:43.008447+00:00 app[web.1]: [00:07:43] Starting 'builder'... 2018-05-16T00:07:44.099608+00:00 app[web.1]: [00:07:44] Finished 'builder' after 1.09 s 2018-05-16T00:07:44.100161+00:00 app[web.1]: [00:07:44] Finished 'build' after 17 s 2018-05-16T00:07:44.363108+00:00 app[web.1]: Loaded "en" Translations successfully. 2018-05-16T00:07:44.901664+00:00 heroku[web.1]: State changed from starting to up 2018-05-16T00:07:44.768429+00:00 app[web.1]: alexa-lgtv-remote listening on port 43548!

pparedes1 commented 6 years ago

ok, happy you got it going again, after the application has run for 15-20 mins you should see the results of the ping that occurs when calling home. If you don't see something like the below, you need to check the value of your CALL_HOME variable.

2018-05-16T00:21:00.848786+00:00 heroku[router]: at=info method=GET path="/" host=xxx.xxxxxxx.com request_id=d8703af8-e549-448e-8cfd-768d11ba3c16 fwd="54.161.176.151" dyno=web.1 connect=0ms service=1ms status=200 bytes=307 protocol=http

StarfighterJ commented 6 years ago

Did another re- do today all is working so far, If the goes to sleep again what is the proper way to wake it up? also take a look at the fresh log why does it not say listening to port 3000? 2018-05-16T17:59:56.660555+00:00 app[web.1]: [17:59:56] Using gulpfile ~/gulpfile.js 2018-05-16T17:59:56.661947+00:00 app[web.1]: [17:59:56] Starting 'build'... 2018-05-16T17:59:56.664196+00:00 app[web.1]: [17:59:56] Starting 'lint'... 2018-05-16T18:00:04.404340+00:00 app[web.1]: [18:00:04] Finished 'lint' after 7.74 s 2018-05-16T18:00:04.404539+00:00 app[web.1]: [18:00:04] Starting 'builder'... 2018-05-16T18:00:05.148770+00:00 app[web.1]: [18:00:05] Finished 'builder' after 744 ms 2018-05-16T18:00:05.149179+00:00 app[web.1]: [18:00:05] Finished 'build' after 8.49 s 2018-05-16T18:00:05.364110+00:00 app[web.1]: Loaded "en" Translations successfully. 2018-05-16T18:00:05.620571+00:00 app[web.1]: alexa-lgtv-remote listening on port 49238! 2018-05-16T18:00:05.978078+00:00 heroku[web.1]: State changed from starting to up

pparedes1 commented 6 years ago

I think that's just normal behavior of Heroku to change ports (see https://stackoverflow.com/questions/28143484/how-does-heroku-route-requests-to-the-correct-port?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa for example), is it working on your local tv?

The fact you are not getting a timeout error suggests it's connecting locally on your network which means it's going to the correct port as expected. You could test it by changing the port forward on your router to make sure that it has only opened the port you've set in the portforward (and Heroku app).

pparedes1 commented 6 years ago

to turn on you can redeploy the app, turn the knob on the dashboard on or off, or make a call to the app, but I designed it so it wouldn't go to sleep every 30 mins. I would just check it after a couple of hours and you should get entries in your log similar to what I posted above (if not, there is an issue).

StarfighterJ commented 6 years ago

Grr where is this knob on the dash? it just went to sleep again look what the log says: My router is set Port forward on 3000.: I know I got the CALLHOME Ver set to http://www.google.com why it not working no clue. 2018-05-16T18:00:05.620571+00:00 app[web.1]: alexa-lgtv-remote listening on port 49238! 2018-05-16T18:00:05.978078+00:00 heroku[web.1]: State changed from starting to up 2018-05-16T18:07:44.084071+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: true } 2018-05-16T18:07:45.024131+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=limitless-cliffs-71488.herokuapp.com request_id=a96cfc1d-b601-4abb-b3f2-1e378f0733eb fwd="72.21.217.119" dyno=web.1 connect=0ms service=1018ms status=200 bytes=360 protocol=https 2018-05-16T18:07:54.726694+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: false } 2018-05-16T18:07:54.789359+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=limitless-cliffs-71488.herokuapp.com request_id=7f5d743f-8b7f-440d-a3b5-5b24f5568a9a fwd="72.21.217.129" dyno=web.1 connect=0ms service=65ms status=200 bytes=360 protocol=https 2018-05-16T18:43:18.955560+00:00 heroku[web.1]: Idling 2018-05-16T18:43:18.956231+00:00 heroku[web.1]: State changed from up to down 2018-05-16T18:43:19.845262+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2018-05-16T18:43:20.118791+00:00 heroku[web.1]: Process exited with status 143

pparedes1 commented 6 years ago

you will need to change the CALLHOME to your application name (from your log I believe it would be https://limitless-cliffs-71488.herokuapp.com/)

Another way for your app to restart is changing variables in your config vars, so once you update it from google.com it should restart, just check the logs.

StarfighterJ commented 6 years ago

Not sure I understand: you want me change My CALLHOME variables Value to https://limitless-cliffs-71488.herokuapp.com/? And I still don't see this Turn on trun off knob I see a re- start all Dyno's under the more tag. I did that last night but Alexa Dev. test would not work. 2018-05-16_li

StarfighterJ commented 6 years ago

It woke up but log seems stuck look: 2018-05-16T19:10:37.953407+00:00 heroku[router]: at=info method=GET path="/" host=limitless-cliffs-71488.herokuapp.com request_id=9c5a6ee2-0f4f-415c-8d39-06ed19e0c60e fwd="196.247.56.44" dyno=web.1 connect=2ms service=8ms status=200 bytes=307 protocol=https 2018-05-16T19:10:38.316738+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=limitless-cliffs-71488.herokuapp.com request_id=2d96e213-9504-4013-9c1c-c9b01f7497a9 fwd="196.247.56.44" dyno=web.1 connect=1ms service=6ms status=404 bytes=394 protocol=https 2018-05-16T19:10:57.849488+00:00 heroku[router]: at=info method=GET path="/)" host=limitless-cliffs-71488.herokuapp.com request_id=b7326aa7-4049-4550-ae72-6d97458828f9 fwd="196.247.56.44" dyno=web.1 connect=2ms service=3ms status=404 bytes=384 protocol=https 2018-05-16T19:11:04.112423+00:00 heroku[router]: at=info method=GET path="/lgtv-remote" host=limitless-cliffs-71488.herokuapp.com request_id=78320871-e875-44c4-a100-eefc1dc67b3b fwd="196.247.56.44" dyno=web.1 connect=2ms service=11ms status=400 bytes=271 protocol=https 2018-05-16T19:11:15.961410+00:00 heroku[router]: at=info method=GET path="/" host=limitless-cliffs-71488.herokuapp.com request_id=8a8f543b-68b2-4c9e-9252-431ebbfb5f84 fwd="196.247.56.44" dyno=web.1 connect=1ms service=2ms status=304 bytes=150 protocol=https 2018-05-16T19:11:43.561656+00:00 heroku[router]: at=info method=GET path="/" host=limitless-cliffs-71488.herokuapp.com request_id=e159ac44-db19-4fc4-bf1a-7d6aee1f0ca9 fwd="174.64.137.32" dyno=web.1 connect=0ms service=3ms status=200 bytes=307 protocol=https 2018-05-16T19:13:25.469662+00:00 heroku[router]: at=info method=GET path="/" host=limitless-cliffs-71488.herokuapp.com request_id=194a4d43-0b48-444d-bb48-7ed1f03c0261 fwd="174.64.137.32" dyno=web.1 connect=0ms service=1ms status=304 bytes=150 protocol=https 2018-05-16T19:13:25.605883+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=limitless-cliffs-71488.herokuapp.com request_id=fbf54b5d-4058-4338-9ae8-83a4e89722cd fwd="174.64.137.32" dyno=web.1 connect=2ms service=1ms status=404 bytes=394 protocol=https 2018-05-16T19:43:35.050348+00:00 heroku[router]: at=info method=GET path="/" host=limitless-cliffs-71488.herokuapp.com request_id=6037282d-5d6c-4ec0-9caf-558727617a90 fwd="174.64.137.32" dyno=web.1 connect=0ms service=4ms status=304 bytes=150 protocol=https 2018-05-16T19:43:35.154059+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=limitless-cliffs-71488.herokuapp.com request_id=95204f28-a40d-466d-b2b1-0eb7405dc087 fwd="174.64.137.32" dyno=web.1 connect=0ms service=4ms status=404 bytes=394 protocol=https

pparedes1 commented 6 years ago

This looks correct, every 15 mins the app is calling your website and staying alive. It should never turn off unless you unplug it. Have you tried testing the app from Alexa? When testing you will see something different in the logs for each request... I think we should be able to close this issue as it is working as intended...

pparedes1 commented 6 years ago

BTW the knob is on the resources tab...

StarfighterJ commented 6 years ago

No it is not working right the Heroku app keeps going into sleep state. But here is what I did, I deleted the CALLHOME config Ver. and the Heroku app does not go into sleep state and the Program re-sets Like it is suppose to, but every 15 mins I have to Accept YES on the TV to send the ID. this is not good. (any thought here)

  1. I know I asked this before but I never did find that File where when you Accept yes on tv What file does the ID go into?
  2. Before I do another re-do I never did a NODE.js Cmd Prompt doing npm install and npm run start, before pushing the program up to Heroku. Should I have done that? reason I am asking would the Accept yes tv ID go up to Heroku permanently? This is a few hours of the log when the CALLHOME Config was deleted, the last part (Bottom) is when I put it back in and you can see where Heroku put it back into sleep state. limitless-cliffs-71488-logs-1526578763789.txt
pparedes1 commented 6 years ago

the reason for the continuous asking for approval is because the app is crashing and/or going to sleep. When you delete the variable CALLHOME, the application crashes. In a recent update I made to the app, this behavior should not occur. If you don't have commit 784000e you should refresh your local repository from mine (or fork again) and you should have it.

In your log I see when you set the variable CALLHOME, but what exactly did you set it to? The reason I ask is because after you set it, it doesn't publish the refresh to the console.

pparedes1 commented 6 years ago

when deploying to Heroku you do not need to install as Heroku does it automatically when you push the code to the remote repository. It's not a real server up all the time, which is why you don't run npm install or npm start. Heroku know when you start the app it should kick off npm start (due to the package.json file). For this reason is why I created this callhome feature to not go to sleep.

If you don't see code in your logs similar to what you posted yesterday, there is a problem...

StarfighterJ commented 6 years ago

ok but do I use the Main Master or the Heroku one?

pparedes1 commented 6 years ago

You can use the master repo, but be sure to set the YARN_PRODUCTION variable to false in your dashboard BEFORE you deploy the app, so that it brings in the developer dependencies and compiles.

StarfighterJ commented 6 years ago

Every went fine except on the Push and there is nothing wrong with my Network connection I tired to push 4 times this is what I am getting:

C:\Users\TEST\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master>git push heroku master Counting objects: 38, done. Delta compression using up to 8 threads. Compressing objects: 100% (31/31), done. Writing objects: 100% (38/38), 81.12 KiB | 4.27 MiB/s, done. Total 38 (delta 1), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: YARN_PRODUCTION=false remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: engines.node (package.json): unspecified remote: engines.npm (package.json): unspecified (use default) remote: engines.yarn (package.json): unspecified (use default) remote: remote: Resolving node version 8.x... remote: Downloading and installing node 8.11.2... remote: Using default npm version: 5.6.0 remote: Resolving yarn version 1.x... remote: Downloading and installing yarn (1.6.0)... remote: Installed yarn 1.6.0 remote: remote: -----> Restoring cache remote: Skipping cache restore (not-found) remote: remote: -----> Building dependencies remote: Installing node modules (yarn.lock) remote: yarn install v1.6.0 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info There appears to be trouble with your network connection. Retrying... remote: info There appears to be trouble with your network connection. Retrying... remote: info There appears to be trouble with your network connection. Retrying... remote: info There appears to be trouble with your network connection. Retrying... remote: error An unexpected error occurred: "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.44.tgz: ESOCKETTIMEDOUT". remote: info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_9069bc36d74f23b525283fa765b33baf/yarn-error.log". remote: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. remote: remote: -----> Build failed remote: remote: We're sorry this build is failing! You can troubleshoot common issues here: remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys remote: remote: Some possible problems: remote: remote: - Node version not specified in package.json remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version remote: remote: Love, remote: Heroku remote: remote: ! Push rejected, failed to compile Node.js app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to obscure-savannah-20835. remote: To https://git.heroku.com/obscure-savannah-20835.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/obscure-savannah-20835.git'

pparedes1 commented 6 years ago

can you try deploying using a github repository instead of using the CLI? Never seen this error so not sure if they are having network issues, VPN on your side or something else.

StarfighterJ commented 6 years ago

Not sure how to deploy using GitHub I have never done that before. Oh wait just tried the Push again looks like it took. must had been a VPN problem and so far working on Alexa Dev. now to wait 30 mins and hope it does not go to sleep. Ah fudge It did go to Sleep Again see log: 2018-05-18T19:35:23.441488+00:00 app[web.1]: [19:35:23] Starting 'builder'... 2018-05-18T19:35:24.669361+00:00 app[web.1]: [19:35:24] Finished 'builder' after 1.23 s 2018-05-18T19:35:24.669747+00:00 app[web.1]: [19:35:24] Finished 'build' after 18 s 2018-05-18T19:35:24.939667+00:00 app[web.1]: Loaded "en" Translations successfully. 2018-05-18T19:35:25.359746+00:00 app[web.1]: alexa-lgtv-remote listening on port 9145! 2018-05-18T19:35:26.028739+00:00 heroku[web.1]: State changed from starting to up 2018-05-18T19:45:45.532640+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: true } 2018-05-18T19:45:45.736667+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=a514b1a6-87ed-4ab3-9ecd-86205745999b fwd="72.21.217.86" dyno=web.1 connect=0ms service=253ms status=200 bytes=360 protocol=https 2018-05-18T19:46:16.060066+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: false } 2018-05-18T19:46:16.158768+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=69213292-20b2-4e69-b8b2-f92e0678e0d0 fwd="72.21.217.119" dyno=web.1 connect=1ms service=104ms status=200 bytes=360 protocol=https Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect... 2018-05-18T19:35:23.441488+00:00 app[web.1]: [19:35:23] Starting 'builder'... 2018-05-18T19:35:24.669361+00:00 app[web.1]: [19:35:24] Finished 'builder' after 1.23 s 2018-05-18T19:35:24.669747+00:00 app[web.1]: [19:35:24] Finished 'build' after 18 s 2018-05-18T19:35:24.939667+00:00 app[web.1]: Loaded "en" Translations successfully. 2018-05-18T19:35:25.359746+00:00 app[web.1]: alexa-lgtv-remote listening on port 9145! 2018-05-18T19:35:26.028739+00:00 heroku[web.1]: State changed from starting to up 2018-05-18T19:45:45.532640+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: true } 2018-05-18T19:45:45.736667+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=a514b1a6-87ed-4ab3-9ecd-86205745999b fwd="72.21.217.86" dyno=web.1 connect=0ms service=253ms status=200 bytes=360 protocol=https 2018-05-18T19:46:16.060066+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: false } 2018-05-18T19:46:16.158768+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=69213292-20b2-4e69-b8b2-f92e0678e0d0 fwd="72.21.217.119" dyno=web.1 connect=1ms service=104ms status=200 bytes=360 protocol=https Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect... 2018-05-18T19:35:23.441488+00:00 app[web.1]: [19:35:23] Starting 'builder'... 2018-05-18T19:35:24.669361+00:00 app[web.1]: [19:35:24] Finished 'builder' after 1.23 s 2018-05-18T19:35:24.669747+00:00 app[web.1]: [19:35:24] Finished 'build' after 18 s 2018-05-18T19:35:24.939667+00:00 app[web.1]: Loaded "en" Translations successfully. 2018-05-18T19:35:25.359746+00:00 app[web.1]: alexa-lgtv-remote listening on port 9145! 2018-05-18T19:35:26.028739+00:00 heroku[web.1]: State changed from starting to up 2018-05-18T19:45:45.532640+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: true } 2018-05-18T19:45:45.736667+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=a514b1a6-87ed-4ab3-9ecd-86205745999b fwd="72.21.217.86" dyno=web.1 connect=0ms service=253ms status=200 bytes=360 protocol=https 2018-05-18T19:46:16.060066+00:00 app[web.1]: Fire of request 'ssap://audio/setMute' with payload: { mute: false } 2018-05-18T19:46:16.158768+00:00 heroku[router]: at=info method=POST path="/lgtv-remote" host=obscure-savannah-20835.herokuapp.com request_id=69213292-20b2-4e69-b8b2-f92e0678e0d0 fwd="72.21.217.119" dyno=web.1 connect=1ms service=104ms status=200 bytes=360 protocol=https 2018-05-18T20:21:57.488976+00:00 heroku[web.1]: Idling 2018-05-18T20:21:57.489648+00:00 heroku[web.1]: State changed from up to down 2018-05-18T20:21:58.233283+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2018-05-18T20:21:58.318063+00:00 heroku[web.1]: Process exited with status 143

pparedes1 commented 6 years ago

Can you confirm your CALLHOME setting in this app? It needs to match the name of your heroku app. What is missing from the log are GET methods, I see when you make calls to Alexa, I just don't see where the app is calling home. Thanks for confirming.

pparedes1 commented 6 years ago

From your log above it appears it should be http://obscure-savannah-20835.herokuapp.com

StarfighterJ commented 6 years ago

Right now it is at Google. com should I Change the CALLHOME var to http://obscure-savannah-20835.herokuapp.com.?

pparedes1 commented 6 years ago

yes, you want the variable to 'call home' which will issue a command to your app every 15 mins and keep Heroku from going to sleep...

StarfighterJ commented 6 years ago

Nice so far it has not gone to sleep, but now having issues after turn off tv with Alexa Dev test after I manually turn it back on when I go test again I get Device is switched off. I end up having to re-start program on Heroku dash board. see examples below:

tv mute

OK. ask lg tv un mute

OK. ask lg tv turn off

There is a problem with the device. ask lg tv turn on

The requested skill took too long to respond ask lg tv mute

The device is switched off.

pparedes1 commented 6 years ago

OK, this seems like an issue with the overall connector and wake on lan functionality, I suspect it's the responses the TV is sending are being misinterpreted as errors . I'll close out this issue and I'll update that issue if I can find what's causing the above.