question

Anshul Sheoliha avatar image
Anshul Sheoliha asked

Pause/Resume working only sometime. What might be the reason?

I am creating a custom music skill. Although I have created the pause and resume intents, along with saving persistent attributes. I am using response interceptors to save the attributes after every request. In the Pause intent, I am saving the offset for the playing stream along with the url and token. It works sometimes, i.e 30% of the times it is invoked for pause/resume it works. Rest of the time it doesn't works. Can anyone tell me what can be the exact reason for this. I check in the database also, it updates the offset sometimes, rest of the time it set's setting as 0 only.

Not sure what is causing this behaviour.

Is it an internet connection issue? or is it a config issue? How can it work sometimes but not work most of the time?

I am assuming it might be because of not so good internet connection.

alexa skills kitalexalambdadeveloper portaldynamodb
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gaetano@Amazon avatar image
Gaetano@Amazon answered

Hello and thanks for posting.

Are you logging all the JSON request/responses? I am wondering if response sent when trying to resume the stream actually has the "offsetInMilliseconds" key filled.

Can you share them please?

Thanks,
Gaetano

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anshul Sheoliha avatar image
Anshul Sheoliha answered

Hi Gaetano,

Thanks for your response. I am not logging all the JSON request/response. Although I am checking in the DynamoDb when I do the pause. Offsetinmilliseconds is not updating in the db itself for those 70% of the times pause is invoked. That's what my concern is, if the logic is correct then why is it working only the 30% of the time. What else can be the reason behind this? Basically I am defaulting it to 0 when the skill is called for the first time. After that I am saving it when pause intent is callled and even in the PlaybackStopped event handler.

Why is that the value is not getting saved in the DB each time, and even though at times it gets saved, then also it fetches the old value. is it something related to read after write consistency? Although i am using the standard persistence adapter. I am not sure how this is achieved, i.e the put command to the table.

So, i am unable to find the exact reason for this. Also, i didn't get a chance to change the internet connection and check. I don't understand if the code logic is working properly then why is it not sometimes. Some data sync issues? How can this be rectified?

I am saving the attributes using response interceptor, just the save operation in that.

Pause intent......
Map<String,Object> attr=input.getAttributesManager().getPersistentAttributes();
Long offset=input.getRequestEnvelope().getContext().getAudioPlayer().getOffsetInMilliseconds();
     
attr.put(Attributes.OffSetInMilliSeconds, offset);
     

Update 1:- After logging the request/response, I am able to check that audioplayer is not sending AudioPlayerStopped event request once the stream is paused or stopped. Although the stop directive is sent to the audioplayer. The offset value is not updated in the DB.

Why is that audioplayer doesn't send event requests all the time?


Update 2 :- After printing the offset in the logs which I am getting from the request, I found that at times the offset is 0. that might be the exact reason behind this problem. Please find below the logs for the pause intent.


2020-09-19T19:24:06.296+05:30    printing request
2020-09-19T19:24:06.296+05:30    {
2020-09-19T19:24:06.296+05:30    "intent": {
2020-09-19T19:24:06.296+05:30    "name": "AMAZON.PauseIntent",
2020-09-19T19:24:06.296+05:30    "confirmationStatus": "NONE"
2020-09-19T19:24:06.296+05:30    },
2020-09-19T19:24:06.296+05:30    "type": "IntentRequest",
2020-09-19T19:24:06.296+05:30    "requestId": "amzn1.echo-api.request.aa71d2e4-53d5-433c-9645-8711a177cd3f",
2020-09-19T19:24:06.296+05:30    "timestamp": {
2020-09-19T19:24:06.296+05:30    "dateTime": {
2020-09-19T19:24:06.296+05:30    "date": {
2020-09-19T19:24:06.296+05:30    "year": 2020,
2020-09-19T19:24:06.296+05:30    "month": 9,
2020-09-19T19:24:06.296+05:30    "day": 19
2020-09-19T19:24:06.296+05:30    },
2020-09-19T19:24:06.296+05:30    "time": {
2020-09-19T19:24:06.296+05:30    "hour": 13,
2020-09-19T19:24:06.296+05:30    "minute": 54,
2020-09-19T19:24:06.296+05:30    "second": 5,
2020-09-19T19:24:06.296+05:30    "nano": 0
2020-09-19T19:24:06.296+05:30    }
2020-09-19T19:24:06.296+05:30    },
2020-09-19T19:24:06.296+05:30    "offset": {
2020-09-19T19:24:06.296+05:30    "totalSeconds": 0
2020-09-19T19:24:06.296+05:30    }
2020-09-19T19:24:06.296+05:30    },
2020-09-19T19:24:06.296+05:30    "locale": "en-IN"
2020-09-19T19:24:06.296+05:30    }
2020-09-19T19:24:06.447+05:30    Size of ExtractedMap: 5
2020-09-19T19:24:06.447+05:30    In Persistence Adaptor Request: path
2020-09-19T19:24:06.447+05:30    Offset: 0
2020-09-19T19:24:06.448+05:30    printing response

As you can view in the above logs, that Offset: 0 is the field which I am printing on console and this is populated from the request I receive.

Thus, I believe there is some problem with the Audio Player Interface. Request you to please check on this @Gaetano@Amazon.


Warm Regards,

Anshul Sheoliha

2 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gaetano@Amazon avatar image Gaetano@Amazon ♦ commented ·

Hello,

It might happen that DB consultations takes more time than usual. I would suggest raising the lambda timeout and try again.

Also, logging the JSON requests and responses would be useful for the troubleshooting.

0 Likes 0 ·
Gaetano@Amazon avatar image Gaetano@Amazon ♦ Gaetano@Amazon ♦ commented ·

Thanks for following up.

Regarding the update 1, it looks like that the DB write operation doesn't succeed because AudioPlayerStopped handler is not even triggered. Is that correct?

Regarding the update 2, how are you retrieving the the value? is it happening on the LaunchRequest?

Please also share the skill-ID so I can have a better look at it.

Thanks!

0 Likes 0 ·