dmhacker / alexa-youtube-skill

Allows Alexa to play audio from YouTube videos
MIT License
243 stars 109 forks source link

Unexpected token C in JSON at position 0 #8

Closed loctruong96 closed 7 years ago

loctruong96 commented 7 years ago

The lamda function was able to found the video when requested, but then crash into this issue: Any suggestions? Thank you!

2017-08-10T10:09:16.713Z    f6cdcd50-7db3-11e7-8359-5f9198326baa    SyntaxError: Unexpected token C in JSON at position 0
at Object.parse (native)
at Request._callback (/var/task/index.js:96:47)
at Request.self.callback (/var/task/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/var/task/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/var/task/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
dmhacker commented 7 years ago

Are you using your own Heroku server or are you referring to https://dmhacker-youtube.herokuapp.com?

loctruong96 commented 7 years ago

I am referring to https://dmhacker-youtube.herokuapp.com , a video was found... but then this error occur right after which leave me kinda stuck as of what may caused the issue.

dmhacker commented 7 years ago

Can you give me a printout of your whole stack log? I'm going to try and reproduce this on my Alexa.

loctruong96 commented 7 years ago

hello, thank you so much for checking. I redeployed the code on lambda to make sure I didn't made any mistake somewhere, and it works now. I probably made some mistakes O_O. I have two unrelated questions wondering if you have the answer to them. First, does the lamda function stream to the echo or the heroku app handle that job? Because aws lamda accept 1gb out free output per month after that we may have problem. Second, I have not very familiar with heroku deployment and wondering if you can give a somewhat detail instructions on how to setup on own heroku youtube processor app like you did? Again thank you!

dmhacker commented 7 years ago

I'll answer both your questions:

  1. The Heroku app streams the actual files. The Lambda server just returns a link to the file on the Heroku server. And, as far as I can tell, with Heroku free servers (which is what dmhacker-youtube is hosted on), you are allocated 550 hours and 2 TB of bandwidth total for all your free dynos each month. Since I'm not really running any other servers consistently, dmhacker-youtube should be fine. In fact, the server automatically shuts off after 30 minutes of inactivity, so it ends up saving free dyno hours that way.

  2. Sure, I'll start rewriting the setup instructions in the README to be more clear and detailed (in the respective repository). Edit: I just updated the setup instructions to be much more clear. It can all be done in a web browser; no need to get messy with the console anymore. :)

loctruong96 commented 7 years ago

Thank you so much for your support!

dmhacker commented 7 years ago

No problem! Glad I could help.