question

newuser-7126b96e-617b-4f47-9bf0-121dd366d22d avatar image
newuser-7126b96e-617b-4f47-9bf0-121dd366d22d asked ·

How to send a recognize request with nghttp2?

I am stuck in this case several days. I only use libnghttp, not libcurl. I send a recognize request with nghttp2 like this:

:method: POST :scheme: https :path: /v20160207/events authorization: Bearer Atza|IwEBIC7NIIcX3TwTprd0JEoIuwaA5vzTgRZ01K-56y_JHHBxu1jt0yvwEqQtv6f5h-oLZLfapziZEYd6hPAmeoBZeSe9M2qcvwxZ0mMGwX-8oWsfkCxoqAEZzqnlhQ_2VXU3qBB5X_EhkctcfBE7-yrNlr_4BXgSiBrBwVfkx9OIqk14At9QQNuyRTDM4DnC7IIIOJ8o3Qo5v4gTP9yh5LGORhqXlRGyWrpzPgwK50EATWQzXWoFrzzHP40doIWOxOHzDBl1YOeP9NaqzKLlpwNYcuN-7SkQgvQ2oXm9_d6tpcEO61lpyL-TY4fM_X-wR3Kuvy245M9J1H0AgjQ1k2eoj7GbzOLGu7Ij_w5Iad8TO3JvXtVOBnZuWXsP2vd2midy1FD0JpRDWUbwUDo1rGzEESVxfpyR9eT8QpjfmFPT98Fp3iI3VI-41ynO3r39fJc8rMXsdvlBfInwyHTdvA-ac8q6XTqGVDM7RN-xcmhEm9gUyMSqZv1ZgM-iS3bsjTt9vexrQlw8JpdaEwtzx9wRlON-NC3VsqyFNh1ohiPL09bqM7wTJprdO41BgDiEVxyuRhk content-type: multipart/form-data; boundary=this-is-a-boundary

file_read_audio_callback buf=========> --this-is-a-boundary Content-Disposition: form-data; name="metadata" Content-Type: application/json; charset=UTF-8

{ "event": { "header": { "namespace": "SpeechRecognizer", "name": "Recognize", "messageId": "86cd0eaf-093e-4c02-8153-4f40cbed29f7", "dialogRequestId": "415d83c4-ffe8-4feb-a228-35b864a9ec3a" }, "payload": { "profile": "CLOSE_TALK", "format": "AUDIO_L16_RATE_16000_CHANNELS_1" } }, "content": [{ "header": { "namespace": "AudioPlayer", "name": "PlaybackState" }, "payload": { "token": "", "offsetInMilliseconds": "0", "playerActivity": "IDLE" } }, { "header": { "namespace": "SpeechSynthesizer", "name": "SpeechState" }, "payload": { "token": "", "offsetInMilliseconds": "0", "playerActivity": "FINISHED" } }, { "header": { "namespace": "Alerts", "name": "AlertsState" }, "payload": { "allAlerts": [], "activeAlerts": [] } }, { "header": { "namespace": "Speaker", "name": "VolumeState" }, "payload": { "volume": "50", "muted": "false" } }] } --this-is-a-boundary Content-Disposition: form-data; name="audio" Content-Type: application/octet-stream

--this-is-a-boundary--

But I cannot receive anything from server and got a message:

[INFO] C ----------------------------> S (GOAWAY)

If I send GET, token invalid, server response invalid token message. But if token is valid, it printed an error message:

FATAL: nghttp2_session_recv: error_code=-507, msg=EOF

How should I do?

valid token

alexa voice servicefeature requestnode_js
10 |2000 characters needed characters left characters exceeded

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

Eric@Amazon avatar image
Eric@Amazon answered ·

I think I see where you're going wrong. Your AudioPlayer/SpeechSynthesizer contexts are incorrect. "payload": { "token": "", "offsetInMilliseconds": "0", "playerActivity": "IDLE" }. offsetInMilliseconds is a long, not a string! Also, same with volume.

10 |2000 characters needed characters left characters exceeded

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

Andy_eat_candy avatar image
Andy_eat_candy answered ·

I actuallly got the same invalidtoken message. I verify the token several times (and update it as well), and the server still give me the same error message as in your first photo. I am using nghttp2 as well. I am wondering @NewUser-7126b96e-617b-4f47-9bf0-121dd366d22d, how did you fix that error?

10 |2000 characters needed characters left characters exceeded

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