c# - Azure服务总线中继连接到未知的IP地址: 40. 112.124.x:9352

标签 c# .net wcf azure azure-servicebusrelay

我们提供使用 Azure 服务总线中继公开到云的本地软件,我们用于公开的基本代码如下(我已经删除了所有可识别的内容):

    ServiceHost sh = new ServiceHost(typeof(BasicHttpEntityService));
    BasicHttpRelayBinding basicHttpRelayBinding = new BasicHttpRelayBinding();

    Uri uriEndPointAddress = ServiceBusEnvironment.CreateServiceUri("https", "ourdomain", "test-url-appendage");
    m_shRelayServiceHost.AddServiceEndpoint(
      typeof(IMyService),
      basicHttpRelayBinding,
      uriEndPointAddress
    ).Behaviors.Add(
      new TransportClientEndpointBehavior
      {
        TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(
          "MyUser",
          "MyPassword")
      });
    sh.Open();

这对于我们的大多数客户来说效果很好,但是,我们的一个客户有严格的防火墙策略。

According to the SB guidelines we have found ,我们要求他们打开 ourdomain.servicebus.windows.net 的端口 9351-9354。现在我们发现,当有传入请求时,该服务会连接到“ourdomain”(我们在 Wireshark 和 WCF 日志中看到此操作成功)以及 40.112.124.x 上的未知(对我们来说)服务: 9352(最后一个八位字节随每个请求而变化)。

通过禁止连接到任何端口上的任何 40.x.x.x 地址,我已经能够在我的开发环境中重现该问题。这是 WCF 日志中发生的情况:

System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions 40.112.124.25:9352

Server stack trace: 
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.RelayedConnectionSession.ConnectAsyncResult.<GetAsyncSteps>b__4(ConnectAsyncResult thisRef, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [0]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.RelayedConnectionSession.EndConnect(IAsyncResult result)

在此期间没有发出 DNS 请求,因此没有主机名可以提供有关此传出连接功能的任何线索。

根据我的调查,this appears to be a Microsoft controlled subnet ,所以我可以接受连接到它的中继服务,但我想知道:

  1. 此附加连接是可选的吗?
  2. 如果不是,我们是否应该允许整个子网?
  3. 此 IP 范围将来会发生变化吗?它是否被硬编码在某个地方?

最佳答案

最后,我们请求微软的支持。 简而言之,他们的答案如下:

  1. 此附加连接是可选的吗?

    No it is not optional. For the relay listener, there is a control channel on port 5671, this connection is always there. Then there is a data channel on portal 9352, this connection established when there is a relay client tries to communicate with the listener.

  2. 这个 IP 范围将来会改变吗?

    Currently, for relay this IP can change, so you need to allow the IP range for the entire datacenter in your region (https://www.microsoft.com/en-us/download/confirmation.aspx?id=41653). The SB product team will be working on to significantly reduce this IP range in the future, to make it much more predictable. There is no exact ETA on this future.

好消息是他们正在努力解决这个问题。坏消息是,现在我们需要将大量 IP 地址添加到白名单中以确保顺利运行。

关于c# - Azure服务总线中继连接到未知的IP地址: 40. 112.124.x:9352,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35873283/

相关文章:

javascript - Fetch API - 状态为 200 的 GET 请求返回空正文

.net - 在 ASP.Net 中使用 Azure.Storage.Queues - 配置 DI

.net - 正则表达式识别方程式中的正数和负数,但不识别运算符

.net - 是否有用于 .NET 的渲染 HTML 差异引擎

c# - QueryStringConverter 因未知原因不工作

wcf - 同一台计算机 WCF 消息交换 => TCP?

c# - 使用 jquery ajax 调用 ASP.NET 静态方法中的输入流来发布表单值

c# - ObjectContext.ExecuteStoreCommand 无法识别参数

c# - 在运行时在 Unity 中解析具有超过 65k 个顶点的网格

javascript - WCF REST 身份验证 - 确定 Web 请求