无法在 AWS API 网关中接收来自 eBay 的 HTTP 通知

Cannot receive HTTP notifications from eBay in AWS API Gateway

我正在尝试配置 eBay Notifications API 以将通知发送到我创建的 AWS API 网关。我已经确认 API 网关可以使用从多个源和 IP 发送的 cURL 命令接收 POST 无需身份验证的 HTTP 请求,所以这不是问题。

这是我使用 SetNotificationPreferences 设置的:

<?xml version="1.0" encoding="UTF-8"?>
<SetNotificationPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    <!-- Use the Developer portal or the <ApplicationDeliveryPreferences> container to set the Application delivery settings -->
    <RequesterCredentials>
        <eBayAuthToken>{token_here}</eBayAuthToken>
    </RequesterCredentials>
    <ErrorLanguage>en_US</ErrorLanguage>
    <WarningLevel>High</WarningLevel>
    <ApplicationDeliveryPreferences>
        <AlertEmail>mailto://{my_email_here}</AlertEmail>
        <AlertEnable>Enable</AlertEnable>
        <ApplicationEnable>Enable</ApplicationEnable>
        <ApplicationURL>{api_gateway_url_here}</ApplicationURL>
        <DeviceType>Platform</DeviceType>
        <DeliveryURLDetails>
            <DeliveryURLName>Email</DeliveryURLName>
            <DeliveryURL>mailto://{my_email_here}</DeliveryURL>
            <Status>Enable</Status>
        </DeliveryURLDetails>
        <DeliveryURLDetails>
            <DeliveryURLName>Gateway</DeliveryURLName>
            <DeliveryURL>{api_gateway_url_here}</DeliveryURL>
            <Status>Enable</Status>
        </DeliveryURLDetails>
    </ApplicationDeliveryPreferences>

    <DeliveryURLName>Email,Gateway</DeliveryURLName>

    <UserDeliveryPreferenceArray>
        <NotificationEnable>
            <EventType>FixedPriceTransaction</EventType>
            <EventEnable>Enable</EventEnable>
        </NotificationEnable>
        <NotificationEnable>
            <EventType>ItemSold</EventType>
            <EventEnable>Enable</EventEnable>
        </NotificationEnable>
        <NotificationEnable>
            <EventType>ItemListed</EventType>
            <EventEnable>Enable</EventEnable>
        </NotificationEnable>
        <NotificationEnable>
            <EventType>ItemRevised</EventType>
            <EventEnable>Enable</EventEnable>
        </NotificationEnable>
    </UserDeliveryPreferenceArray>
</SetNotificationPreferencesRequest>

我还打电话给 GetNotificationPreferences 以确保首选项已正确保存,而且确实如此。

我在电子邮件地址收到 XML 通知,但我没有收到 HTTP 请求。

有没有其他人成功配置 eBay 以将通知发送到 AWS 或其他 HTTP 端点?我愿意更改我的技术堆栈,例如设置 EC2 服务器而不是API 网关端点。

我怀疑 eBay 通知 API 无法连接到 AWS API 网关,因为我过去遇到过这个问题。例如,另一个 RESTful API 服务不支持 AWS API 网关连接所需的 TLS 1.2 协议,但我还没有证明这是这种情况。我将设置另一个非 AWS API 网关 HTTP 端点服务来接收来自 eBay 的请求来测试这个理论。

更新 1

再观察堆栈 24 小时后,我看到通过 AWS API 网关从 eBay 通知 API 多次成功调用。但是,成功的 HTTP 调用数与发送的电子邮件数不匹配。我仍然按照上面的方式设置通知首选项,并且我收到的电子邮件通知数量与我观察到的事件数量一样多。

但是,我没有收到我期望的所有 HTTP 通知。我无法确定 HTTP 通知成功的模式,因为它们包括来自四个启用事件中每一个的通知,包括以下 SOAP 类型:GetItemResponseGetItemTransactionsResponse.

注意:我没有足够的时间成功设置另一个非 AWS API 网关 Web 服务器来接收 HTTP 通知以隔离 AWS 本身是否是问题所在。我不排除这不是 eBay 的错的可能性 ;-)。我愿意接受有关完成此任务的最简单方法的建议。我一直在寻找像 Mockbin 这样的工具,但我更喜欢使用 HTTPS 的工具。

更新 2

我发现 Webhook Tester and configured eBay to send Notifications to the custom site. I triggered a few events in eBay, and I was surprised to see the notifications coming through both the email and the Webhook Tester, but no Notifications came through the API Gateway. I'm still not sure why the API Gateway is either not receiving or not accepting the requests consistently from eBay. I'd prefer to keep using API Gateway, but it seems that in a pinch I could use the code from Webhook Tester 可以构建我自己的网络服务器端点。

更新 3

一时兴起,我更改了 API 网关中的 端点类型 边缘优化区域。我在 eBay 中触发了更多事件,并让它单独运行 2 小时以捕获系统触发的事件。我现在看到更多一致的事件被发送到 API 网关。我不确定为什么此更改会产生如此大的不同,我打算对其进行更多研究。

作为参考,以下是在无服务器项目中配置端点类型的方法: https://serverless.com/framework/docs/providers/aws/events/apigateway/#configuring-endpoint-types

也有帮助: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html

在观察了几天从 eBay 通知到 AWS 的 API 网关的请求后,我准备说将端点类型更改为 'regional' 解决了这个问题。我不能确定为什么,但我可以肯定地说我收到了我期望收到的所有事件。

如果有人有关于此更改为何有效的更多信息,我会洗耳恭听。 :-)

编辑

根据评论中的要求,这里是 serverless.yml 文件:

service: party-light

plugins:
  - serverless-offline

provider:
  name: aws
  endpointType: REGIONAL
  runtime: nodejs8.10
  stage: dev
  region: us-east-1
  memorySize: 128

  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "iot:*"
      Resource:
        - "*"
    - Effect: 'Allow'
      Action:
        - 's3:PutObject'
      Resource:
        - 'arn:aws:s3:::{MY_S3_BUCKET}/*'

functions:
  party:
    handler: handler.party
    events:
      - http:
          path: party
          method: post