【问题标题】:Unable to connect to 127.0.0.1 endpoint programatically when running Azure InternalEndpoint locally in Emulator在模拟器中本地运行 Azure 内部终结点时,无法以编程方式连接到 127.0.0.1 终结点
【发布时间】:2014-07-20 00:05:29
【问题描述】:

我无法让本地环境在模拟器中运行所需的 Azure 部署。

我有一个 WebRole (MyWebSite) 有一个公共 (InputEndpoint),还有一个 WebRole 有一个 InternalEndpoint (MyServiceApplication)。 InternalSite 具有一组向 PublicSite 公开的 WCF 服务。

  <WebRole name="MyServiceApplication"  vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="MyInternalEndpoint" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InternalEndpoint name="MyInternalEndpoint" port="8083" protocol="http"></InternalEndpoint>
    </Endpoints>
  </WebRole>
  <WebRole name="MyWebSite" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
  </WebRole>

我从 MyWebSite 以编程方式连接到 MyServiceApplication 端点。即。

var applicationRole = RoleEnvironment.Roles["MyServiceApplication"].Instances.First().InstanceEndpoints["MyInternalEndpoint"].IPEndpoint;
var endPointAddress = string.Format("http://{0}:{1}/MyService.svc", applicationRole.Address, applicationRole.Port);
var channel = channelFactory.CreateChannel(new EndpointAddress(endPointAddress));

endPointAddress 变量在 Azure Emulator Express 运行时结果为 http://127.0.0.1:8083/MyService.svc,但它抱怨:

http://127.0.0.1:8083/MyService.svc 上没有可以接受消息的端点监听。

但是,当我通过 http://localhost:8083/MyService.svc 浏览到此端点时,我没有问题。

所以我想问题是,如何在 Azure Emulator Express(而不是 localhost)中让 InternalEndpoint 绑定到 127.0.0.1,或者有一种方法可以以编程方式将端点解析为 http://localhost:8083/MyService.svc ?

希望有人能帮忙,

【问题讨论】:

    标签: .net wcf azure iis-express azure-emulator


    【解决方案1】:

    对于任何感兴趣的人,当我以管理员权限运行 Visual Studio 时,这两个角色都绑定到 127.0.0.1(而不是 localhost)。

    不完全确定为什么会这样,但它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      相关资源
      最近更新 更多