API-шлюз: нормально на кнопке ТЕСТ, 500 на скручиваемости - PullRequest
0 голосов
/ 11 января 2019

Я проверил все конфигурации и до сих пор не могу понять, почему это происходит ... Моя конечная точка:

aws api gateway post polly

aws api gateway method request

aws api gateway integration request polly

aws api gateway integration response

aws api gateway method response

Мои успешные входы в ТЕСТ:

Execution log for request 24899adf-15c1-11e9-8131-9fdcec088245
Fri Jan 11 16:51:29 UTC 2019 : Starting execution for request: 24899adf-15c1-11e9-8131-9fdcec088245
Fri Jan 11 16:51:29 UTC 2019 : HTTP Method: POST, Resource Path: /
Fri Jan 11 16:51:29 UTC 2019 : Method request path: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request query string: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request headers: {}
Fri Jan 11 16:51:29 UTC 2019 : Method request body before transformations: 
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request URI: https://polly.eu-central-1.amazonaws.com//v1/speech
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request headers: {Authorization=***************************************************************************************************************************************************************************************************************************************************************************13f5d3, X-Amz-Date=20190111T165129Z, x-amzn-apigateway-api-id=ij6dyda1c4, Accept=application/json, User-Agent=AmazonAPIGateway_ij6dyda1c4, X-Amz-Security-Token=AgoGb3JpZ2luEK3//////////wEaCWV1LXdlc3QtMSKAAr1iooeT2rTwuuVQKVSAHDACPlRVsEAYoF7p4DnkjiUEYLS0eSMacs3+eLRt+PgpuKW7JvsZB435KWxYXcvWOYQ7KdHlHWX+M/S9tDVDDVBWJtftnv5WM26DYJHv5mHr/YHCefsW7VxRPqoB9uBea9hJ3ph2fN+NyLo/CeIrPgFuhkaex0gE4/j3DvLB+8Jqq3yFor9fLNFSI6hmNUUHBGcwmlDMr3j8QNht6OUZgg4TADmTIZhpo0V+ih3G0wzGm3/xm7fUKe7fZ//DJs6VTBBHahJ+2JdEXQ8dh8jEsRaJEb2n9cwDFlf1GLQiK56UGP+vmCorRwJjm6m6tveM/C4qigMIkv//////////ARAAGgwzMzYzMTkxMzM4MzgiDPuvnkrf52NaQ7BjZSreAhZw7AXI8UGATS35mtkqoKb1LIj4lyc7nTKgZXtim4KDYPHu1eypQwtnx9c93GxDy6dkz4GLvDayqWHy513K3hqsJlgXFEBtNBd6XA4rXY/t [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Endpoint request body after transformations: {
   "OutputFormat": "ogg_vorbis",
   "Text": "string",
   "TextType": "text",
   "VoiceId": "Joanna"
}
Fri Jan 11 16:51:29 UTC 2019 : Sending request to https://polly.eu-central-1.amazonaws.com//v1/speech
Fri Jan 11 16:51:29 UTC 2019 : Received response. Integration latency: 164 ms
Fri Jan 11 16:51:29 UTC 2019 : Endpoint response body before transformations: OggSVd&�vorbis"V��OggSP��G�������������vorbisffmpegvorbis"BCV@B*�c�:�!���B�)�B�!�$C�:�5�cG�d�BɁАU@�WPrI-�s�W�q� �s� g�q   %�s�9�r�1�s�Wr)-�s�G�q��s�G�q��sm1��r�9�s� �Rr�5�s�gr%�s� g�q� �s�5��r�9�s�9�s�9�s�1�s�9�sn1�s�9�s�9�s�9�s 4d���(��(�
�@qG�K���$

Y�H��H��X�fi�&z�(��*��iʲ,˲�.�
HPQ�p
Yd`(��8��X��Y�����PG�M�$��<��<��<��<��<��<��<

Y �(dBCV@!C�R\
BCB�C����)�%c�S�A!|�=��{�АUa8���$!�b'Dq� !��$X�y�$݃B��{˹��{ 4d� �B!�B)��RH)��b� [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Endpoint response headers: {Content-Type=audio/ogg, Date=Fri, 11 Jan 2019 16:51:29 GMT, x-amzn-RequestCharacters=6, x-amzn-RequestId=24a5395f-15c1-11e9-b3b5-f3a03497eaec, transfer-encoding=chunked, Connection=keep-alive}
Fri Jan 11 16:51:29 UTC 2019 : Method response body after transformations: OggSVd&�vorbis"V��OggSP��G�������������vorbisffmpegvorbis"BCV@B*�c�:�!���B�)�B�!�$C�:�5�cG�d�BɁАU@�WPrI-�s�W�q� �s� g�q  %�s�9�r�1�s�Wr)-�s�G�q��s�G�q��sm1��r�9�s� �Rr�5�s�gr%�s� g�q� �s�5��r�9�s�9�s�9�s�1�s�9�sn1�s�9�s�9�s�9�s 4d���(��(�
�@qG�K���$

Y�H��H��X�fi�&z�(��*��iʲ,˲�.�
HPQ�p
Yd`(��8��X��Y�����PG�M�$��<��<��<��<��<��<��<

Y �(dBCV@!C�R\
BCB�C����)�%c�S�A!|�=��{�АUa8���$!�b'Dq� !��$X�y�$݃B��{˹��{ 4d� �B!�B)��RH)��b�)� [TRUNCATED]
Fri Jan 11 16:51:29 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=1-5c38c991-0ada2ff083880c6182550904, Access-Control-Allow-Origin=*, Content-Type=audio/ogg}
Fri Jan 11 16:51:29 UTC 2019 : Successfully completed execution
Fri Jan 11 16:51:29 UTC 2019 : Method completed with status: 200

Но в curl:

curl -vd POST https://ij6dyda1c4.execute-api.eu-west-1.amazonaws.com/test
*   Trying 54.230.228.34...
* TCP_NODELAY set
* Connected to ij6dyda1c4.execute-api.eu-west-1.amazonaws.com (54.230.228.34) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.execute-api.eu-west-1.amazonaws.com
*  start date: Oct  9 00:00:00 2018 GMT
*  expire date: Oct  9 12:00:00 2019 GMT
*  subjectAltName: host "ij6dyda1c4.execute-api.eu-west-1.amazonaws.com" matched cert's "*.execute-api.eu-west-1.amazonaws.com"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fa8ef800400)
> POST /test HTTP/2
> Host: ij6dyda1c4.execute-api.eu-west-1.amazonaws.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 500 
< content-type: application/json
< content-length: 36
< date: Fri, 11 Jan 2019 16:46:16 GMT
< x-amzn-requestid: 69bba4ef-15c0-11e9-9029-471cfe507f1d
< x-amz-apigw-id: TWQ9zE4XDoEF2Cg=
< x-cache: Error from cloudfront
< via: 1.1 b3b1689b5de3293227c415784ed3c268.cloudfront.net (CloudFront)
< x-amz-cf-id: 5CmlH1PrYXKv_SP6QxHmH75WaovcewgZeWZcPuuZwDCsKHeQxfKd9Q==
< 
* Connection #0 to host ij6dyda1c4.execute-api.eu-west-1.amazonaws.com left intact
{"message": "Internal server error"}

И развертывание я не забыл: aws api gateway deployment history

Также я вижу, что записано 500 таких обращений: aws api gateway dashboard statistic calls errors

В CloudWatch я нашел: Execution failed due to configuration error: Unable to transform response.

Ответы [ 2 ]

0 голосов
/ 14 января 2019

В запросе добавьте заголовок Accept: x-amazon-apigateway-binary-media-types.

Но при этом я могу получить только base64, те же 500, когда я установил Convert to binary (if needed).

0 голосов
/ 11 января 2019

В большинстве случаев это связано с проблемой «Deploy API». Вы забыли развернуть после внесения изменений?

Вы также можете просмотреть историю развертывания на этих этапах.

Включить бинарную поддержку для шлюза API: EDIT1:

Единственная часть, которая отсутствует, - это возможность прохождения ответа. Ознакомьтесь с тем, как отправить бинарный ответ от лямбды или других сервисов.

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-configure-with-console.html

С другой стороны у вас возникнет проблема, когда размер превысит 6 МБ. Если размер маленький, то хорошо.

...