Question

I have an internal endpoint setting as below:

<InternalEndpoint name="TcpSvcEndpoint" protocol="tcp" port="20000" />

The endpoint will be used by a NetTcp WCF Service. Configuration works fine if I have 1 instance running in compute emulator. But with 2 or more instance in compute emulator (Visual Studio debugging Azure project), same port gets assigned to all of the instances. This of course fails WCF NetTcp initialization for all services (except for the very first instance) with expected exception "There is already a listener on IP endpoint. Make sure ..... SocketException: Only one usage of each socket .....".

My understanding was that the emulator will increment the port for each instance. If thats not the case, how do you test multiple instances on compute emulator while debugging in Visual Studio?

I don't want to use the dynamic port setting with "*".

For clarification, I am accessing the RoleEnvironment to get the assigned port.

RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["TcpSvcEndpoint"].IPEndpoint.Port;

I am using Azure SDK 1.6. (Nov. 2011 version).

Was it helpful?

Solution

With Windows Azure SDK 1.5 and above multiple instances have different IP address but the same port as defined in EndPoint settings as described my this blog.

They way it works is that, if you have defined a TCP endpoint with port 10000 with 2 instance then you will get Instance IP address as below:

  • Instance #1 - 127.255.0.1:10000
  • Instance #2 - 127.255.0.2:10000

So if you have to test all the instances of a service in compute emulator. you would need to get the IPAddress and the Port combined to test the application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top