Nagoh
Nagoh

Reputation: 813

Unable to connect to 127.0.0.1 endpoint programatically when running Azure InternalEndpoint locally in Emulator

I'm having trouble getting my local environment to run my desired Azure deployment in the emulator.

I have one WebRole (MyWebSite) that has a public (InputEndpoint), and one WebRole that has an InternalEndpoint (MyServiceApplication). The InternalSite has a set of WCF services that it exposes to the PublicSite.

i.e.

  <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>

I connect to MyServiceApplication endpoints programtically from MyWebSite. ie.

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));

The endPointAddress variable turns out to be http://127.0.0.1:8083/MyService.svc at runtime in Azure Emulator Express, however it complains:

There was no endpoint listening at http://127.0.0.1:8083/MyService.svc that could accept the message.

However, when I browse to this endpoint via http://localhost:8083/MyService.svc, I have no issue.

So I guess the question is, how can I get the InternalEndpoint to bind to 127.0.0.1 in Azure Emulator Express (as opposed to localhost), or is there a way that I can programmatically resolve the endpoint to be http://localhost:8083/MyService.svc?

Hope someone can help,

Upvotes: 0

Views: 814

Answers (1)

Nagoh
Nagoh

Reputation: 813

For anyone that is interested, both roles bind to 127.0.0.1 (as opposed to localhost) when I run Visual Studio with Administrator privileges.

Not entirely sure why this is the case, but it has done the trick for me.

Upvotes: 1

Related Questions