Play Track not working with AWS presigned URL


#1

I’m trying to use webcore to play a track stored in s3. I’m using a presigned URL. I can hit the url in a private browsing window and it works just fine, but for some reason, webcore doesn’t work. I Test the piston and the audio devices wake up like they should, but then they never play the URL. It’s got some funky characters in it, so I’m wondering if that’s the problem. Here’s the URL: (It’s got a 1 week expiration, so if you’re looking at this more than 1 week from when I post/edit this, it’s not going to work. Just let me know and I’ll make you a new URL)

https://home-sounds-for-smartthings.s3.amazonaws.com/Yzma%20Dinner%20Time.mp3?AWSAccessKeyId=AKIAJHKITAFHDCUQNIJQ&Expires=1513068555&Signature=FwDwE%2FQJXaIkz0R%2Fnm9QOAB8WGM%3D

The URL was created with the aws cli’s presign method: https://docs.aws.amazon.com/cli/latest/reference/s3/presign.html

Thanks!


#2

I wonder if, when the ST cloud reaches out to s3 to grab the file, it’s using some ST AWSAccessKeyId and that’s overriding the one in the presigned URL. That’d be annoying…

But honestly, I have no idea if that’s what’s going on. What’s a good way to get logs of exactly what’s happening when I run this?


#3

#4


#5

This is a long shot, but some times when WC works with URLs you get { } where you don’t want them. You could try something like:
WITH

  • Music Player
    DO
  • Set variable {songURL} to
    Play track {yourVariable}

I don’t have any music players myself or anything presigned in S3 to test this out tho.

What error are you getting when you trace the log?


#6

Nope, looks like that didn’t work. It still does the same thing. When I hit “Test” it connects to the Chromecast device (I can hear the connection sound), then just doesn’t play anything.
If I modify the object in s3 to have global read permissions, everything works. But I’d rather not do that if possible.
Here are the logs:

+0ms    ╔Received event [My location].test = 1512533226255 with a delay of 97ms
+113ms  ║RunTime Analysis CS > 15ms > PS > 72ms > PE > 26ms > CE
+122ms  ║Runtime (36644 bytes) successfully initialized in 72ms (v0.2.0ff.20171129) (121ms)
+123ms  ║╔Execution stage started
+127ms  ║║Cancelling statement #1's schedules...
+142ms  ║║Executed virtual command [Main Floor].setVariable (9ms)
+756ms  ║║Executed physical command [Main Floor].playTrack([https://home-sounds-for-smartthings.s3.amazonaws.com/Yzma%20Dinner%20Time.mp3?AWSAccessKeyId=AKIAJHKITAFHDCUQNIJQ&Expires=1513707935&Signature=jg0omD0jPkZwrOqfBCf6T7w3c%2BM%3D]) (611ms)
+757ms  ║║Executed [Main Floor].playTrack (613ms)
+759ms  ║╚Execution stage complete. (636ms)
+965ms  ╚Event processed successfully (965ms)

The log doesn’t really show that there’s an error…


#7

Update! Shortening the URL with something like http://is.gd fixes the problem. I stick the presigned url in and then call playTrack on the short url. Why though… Maybe there’s some weird characters that don’t play nice with playTrack?

For reference, here’s the full URL:

https://home-sounds-for-smartthings.s3.amazonaws.com/Yzma%20Dinner%20Time.mp3?AWSAccessKeyId=AKIAJHKITAFHDCUQNIJQ&Expires=1513707935&Signature=jg0omD0jPkZwrOqfBCf6T7w3c%2BM%3D

and the shortened one:

https://is.gd/mJEhHC

#8

Just for giggles take the full url and replace all the encoding variables with what they actually are. IE %20 is a space

See if this works?


#9

Nope, looks like that doesn’t work. I tried it with everything decoded:

https://home-sounds-for-smartthings.s3.amazonaws.com/Yzma Dinner Time.mp3?AWSAccessKeyId=AKIAJHKITAFHDCUQNIJQ&Expires=1513707935&Signature=jg0omD0jPkZwrOqfBCf6T7w3c+M=

And with everything but the spaces decoded:

https://home-sounds-for-smartthings.s3.amazonaws.com/Yzma%20Dinner%20Time.mp3?AWSAccessKeyId=AKIAJHKITAFHDCUQNIJQ&Expires=1513707935&Signature=jg0omD0jPkZwrOqfBCf6T7w3c+M=

Neither works.


#10

Interesting. Figured it might have just been encoding the already encoded characters