我有一个托管在 Azure 中的 Azure 服务总线中继,它公开了类似于以下端点的端点: https://myTestSB.servicebus.windows.net/MyService/LogIn()
有趣的是,当我调用此服务总线时,它会进行 4 次调用,如下所示。 这是导致响应缓慢的原因。
有人可以吗 澄清发生了什么 每次通话时?第一个调用 #1 是否必须等待 2、3 和 4?
1(需要很长时间)
GET https://myTestSB.servicebus.windows.net/MyService/LogIn()?$filter=UserID eq '1234' and Password eq 'secret'
User-Agent: Microsoft ADO.NET Data Services
.....
Status Code: OK 200
...
2
CONNECT https://myTest-sb.accesscontrol.windows.net/WRAPv0.9/
Status Code: OK 200
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
3
POST https://TestSB-sb.accesscontrol.windows.net/WRAPv0.9/
Content-Type: application/x-www-form-urlencoded
Host: TestSB-sb.accesscontrol.windows.net
Content-Length: 307
Expect: 100-continue
Connection: Keep-Alive
Status Code: OK 200
.......
4
CONNECT https://myTestSB.servicebus.windows.net/MyService/LogIn()?$filter=UserID eq '1234' and Password eq 'secret'
Status Code: OK 200
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
登录服务总线需要 5-10 秒,而在本地环境中只需不到一秒。不确定服务总线为何以及如何增加延迟。
最佳答案
默认情况下,Azure 服务总线中继通常通过 ACS 使用选择加入身份验证 ( Access Control Services )。为了使用中继端点 - 它必须首先使用 ACS token 授权 WCF channel 。如果您选择不使用 ACS you are providing your own relay access control,则可以通过配置删除您看到的额外调用。 。
禁用 ACS 进行服务总线中继(选择退出)
<bindings>
<netTcpRelayBinding>
<binding name="default">
<security relayClientAuthenticationType="None" />
</binding>
</netTcpRelayBinding>
</bindings>
更多详情,请参阅 MSDN on securing Azure Service Bus Connections .
至于延迟问题(5-10 秒) - 这一切都取决于使用的 WCF 调用数量、您与数据中心的关系以及共享的数据量。有许多选项可以调整上述所有内容。另外ensure you have configured your firewall properly for establishing Azure Relay communication .
关于wcf - Azure 服务总线中继响应缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17987846/