AWS SNSClient 发布请求超时错误

Timeout error for AWS SNSClient Publish request

这是一段代码:

                        //Publishing the topic
                        snsClient.Publish(new PublishRequest
                        {
                            Subject = Constants.SNSTopicMessage,
                            Message = snsMessageObj.ToString(),
                            TopicArn = Settings.TopicArn
                        });

我收到以下错误:

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

这里是详细错误的截图:

但不知道如何解决这个问题。任何提示或 link 都会有所帮助。

当满足以下一个或多个条件时,可能会出现此问题:

• 发生网络中断。

• 代理服务器阻止了 HTTP 请求。

• 出现域​​名系统 (DNS) 问题。

• 出现网络身份验证问题。

[https://nilangshah.wordpress.com/2007/03/01/the-underlying-connection-was-closed-unable-to-connect-to-the-remote-server/]1

  • 确保您的有效负载大小不应超过 256 kb
  • 确保您已配置 PutObjectRequest
  • 的超时 属性

查看示例 aws sns 请求代码(来自 )

// Create topic
string topicArn = client.CreateTopic(new CreateTopicRequest
{
    Name = topicName
}).CreateTopicResult.TopicArn;

// Set display name to a friendly value
client.SetTopicAttributes(new SetTopicAttributesRequest
{
    TopicArn = topicArn,
    AttributeName = "DisplayName",
    AttributeValue = "Whosebug Sample Notifications"
});

// Subscribe an endpoint - in this case, an email address
client.Subscribe(new SubscribeRequest
{
    TopicArn = topicArn,
    Protocol = "email",
    Endpoint = "sample@example.com"
});

// When using email, recipient must confirm subscription
Console.WriteLine("Please check your email and press enter when you are subscribed...");
Console.ReadLine();

// Publish message
client.Publish(new PublishRequest
{
    Subject = "Test",
    Message = "Testing testing 1 2 3",
    TopicArn = topicArn
});

// Verify email receieved
Console.WriteLine("Please check your email and press enter when you receive the message...");
Console.ReadLine();

// Delete topic
client.DeleteTopic(new DeleteTopicRequest
{
    TopicArn = topicArn
});

我们遇到了完全相同的问题。我们每天收到大约 40 次此错误,不到我们发送的成功推送通知的 0.1%。

我们的解决方案?将 AWSSDK NuGet 包从 1.5.30.1 更新到 2.3.52.0(最新的 v2 版本,以便于升级)。我们一更新,错误就停止了。我查看了很多发行说明,但找不到任何特别提及此问题的内容。我们不知道为什么更新有效,但确实有效。

我希望这可以帮助您和其他人解决这个问题。