2

我检查了所有配置,但仍然无法理解为什么会发生...我的端点:

aws api 网关 post polly

aws api网关方法请求

aws api 网关集成请求 polly

aws api 网关集成响应

aws api网关方法响应

我在测试中的成功日志:

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�&amp;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 网关部署历史

我还看到记录了这 500 次点击: aws api 网关仪表板统计调用错误

在 CloudWatch 中,我发现:Execution failed due to configuration error: Unable to transform response.

4

2 回答 2

1

大多数情况下,这是由于“部署 API”问题。更改后忘记部署了吗?

您还可以在这些阶段检查部署历史记录。

为 API Gateway 启用二进制支持:EDIT1:

缺少的一个部分是启用响应的直通。查看如何从 lambda 或其他服务发送二进制响应。

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

另一方面,当大小超过 6 MB 时,您将遇到问题。如果尺寸小,那很好。

于 2019-01-11T19:36:23.087 回答
0

在您的请求中添加 header Accept: x-amazon-apigateway-binary-media-types

但是这样我只能得到base64,和我设置时一样的500 Convert to binary (if needed)

于 2019-01-14T07:51:44.947 回答