Windows 8 Azure Emulator is Remapping Port 80 to 8

2019-07-19 07:10发布

问题:

I was developing a project with a WCF REST and TCP(inter-role) endpoint on Windows 7. I just upgraded to Windows 8 and now I have serious problems with it.

First of all, when I deploy my project to azure I get these warnings:

Windows Azure Tools: Warning: Remapping private port 80 to 81 in role 'OfisimCRM.WebClient' to avoid conflict during emulation.

Windows Azure Tools: Warning: Remapping private port 443 to 446 in role 'OfisimCRM.WebClient' to avoid conflict during emulation.

Skype is disabled and it is not the issue.

this is not so important but the important thing is I'm getting more serious errors from my interrole communication requests although I disabled firewall completely. Here it is:

Could not connect to net.tcp://127.255.0.0:22000/NotifyService. The connection attempt lasted for a time span of 00:00:01.1820716. TCP error code 10061: No connection could be made because the target machine actively refused it 127.255.0.0:22000.  - 
Server stack trace: 
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

TCP client code:

public static LicenseItem CheckLicense(int userID)
{
    // This instance does not exist in memory cache. Check if other servers in the same web role know anything about this instance.
    var webRoles = RoleEnvironment.Roles["OfisimCRM.WebClient"];
    var myID = RoleEnvironment.CurrentRoleInstance.Id;
    LicenseItem remoteValue = null;
    foreach (var targetInstance in webRoles.Instances)
    {
        // I am currently going through a loop of instances. Check if the current enumaration shows my address.
        if (targetInstance.Id == myID)
        {
            // Skip.
        }
        else
        {
            // This is a neighbour instance. Check to see if it knows about the instance I'm looking for.
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            EndpointAddress targetAddress = new EndpointAddress(
                String.Format("net.tcp://{0}/NotifyService", targetInstance.InstanceEndpoints["NotificationServiceEndPoint"].IPEndpoint)
                );

            ChannelFactory<INotifyService> channelFactory = new ChannelFactory<INotifyService>(binding, targetAddress);
            INotifyService targetClient = channelFactory.CreateChannel();

            try
            {
                remoteValue = targetClient.CheckLicense(userID);
                if (channelFactory.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    channelFactory.Close();
                }
            }
            catch (TimeoutException timeoutException)
            {
                Trace.TraceError("Unable to check license on web role instance '{0}'. The service operation timed out. {1}", myID, timeoutException.Message);
                ((ICommunicationObject)targetClient).Abort();
            }
            catch (CommunicationException communicationException)
            {
                Trace.TraceError("Unable to check instance on web role instance '{0}'. There was a communication problem. {1} - {2}", myID, communicationException.Message, communicationException.StackTrace);
                ((ICommunicationObject)targetClient).Abort();
            }
        }
    }
    return remoteValue;
}

Edit 1: Important Update:

I think the problem is about the second instance. I did a debug and I saw the connection refused only by this stopped instance. I think this explains everything but I don't know why it is happening.

Edit 2: Temprorary Solution:

I noticed that is not an issue about Windows 8 because I was upgraded Azure SDK June 2012 SP1 to Fall 2012. I downloaded the not upgraded version of my project from TFS than I saw it's working. In conclusion, its the Azure SDK but I don't know why.

回答1:

Remapping port numbers is not symptom for issues at all. It is normal behavior and has always been. While doing/configuring your Windows 8 Dev Box, did you install the "Windows Features" WCF Activation:

Another way to test whether your Service is actually up and running is to:

  • Make sure you have the endpoint by launching the Compute Emulator and expecting the local deployment
  • telnet on the provided IP and port number to see whether a connection can actually be established

Verify endpoints UI:

Well, this will show you the Input endpoints. And from what I see you are using Internal Endpoints. Just for the sake of trial, try changing them to Input to see whether there will be some change in behavior.

But first check out that you have installed the WCF Activation.



回答2:

I always get this issue when I forget to unbind the default web site in IIS (full IIS) on my dev box. Did you remember to do that? By default, your local IIS will bind http to port 80 on the 'Default Web Site'. If you edit that binding (using inetmgr) to another port, then the emulator can grab 80.