第一次调用Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync超时,后续调用不会

时间:2019-02-27 16:25:16

标签: azure servicebus

我编写了一些代码来与azure服务总线通信。它将消息发送到队列。它在针对.net标准2.0的项目中

当我从.net核心终端应用程序运行时,它运行良好。但是,当从.net framework 4.7.2项目调用相同的代码时,第一次尝试发送消息会在30到90秒后导致以下异常:

"The remote party closed the WebSocket connection without completing the close handshake."

但是任何其他消息都将毫无问题地发送。

// This is using Microsoft.Azure.ServiceBus, if that makes any difference... 

MessageSender MessageSender  = new MessageSender(ConnectionString, SendQueueName;

try
{
     await MessageSender.SendAsync(new Message(Encoding.UTF8.GetBytes("Test that won't work")));
}
catch(Exception e)
{
    // Error will be caught here:
    // "The remote party closed the WebSocket connection without completing the close handshake."
}
await MessageSender.SendAsync(new Message(Encoding.UTF8.GetBytes("Test that will work")));

有人知道为什么第一次通话失败吗?以及如何使其不失败?还是更快地失败?我曾尝试更改OperationTimeout和RetryPolicy,但它们似乎没有任何作用。

1 个答案:

答案 0 :(得分:0)

这些第一个连接是通过端口5671/56712进行的,趋势科技防病毒软件会拦截这些端口。一旦这些超时,框架就会回到使用443的状态,

我们尝试关闭趋势并运行测试连接及其几乎瞬时。