2

我在 Windows 7 上开发了一个带有 WCF REST 和 TCP(角色间)端点的项目。我刚刚升级到 Windows 8,现在我遇到了严重的问题。

首先,当我将项目部署到 azure 时,会收到以下警告:

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 已禁用,这不是问题。

这不是那么重要,但重要的是我从我的交互通信请求中得到了更严重的错误,尽管我完全禁用了防火墙。这里是:

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客户端代码:

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

编辑 1:重要更新:

IIS 状态

我认为问题在于第二个实例。我做了一个调试,我看到连接只被这个停止的实例拒绝。我认为这解释了一切,但我不知道为什么会这样。

编辑 2:临时解决方案:

我注意到这不是关于 Windows 8 的问题,因为我将 Azure SDK June 2012 SP1 升级到了 2012 年秋季。我从 TFS 下载了我的项目的未升级版本,而不是我看到它正在工作。总之,它是 Azure SDK,但我不知道为什么。

4

2 回答 2

2

重新映射端口号根本不是问题的征兆。这是正常行为,而且一直如此。在执行/配置您的 Windows 8 Dev Box 时,您是否安装了“Windows 功能”WCF 激活:

WCF 行动

测试您的服务是否实际启动并运行的另一种方法是:

  • 通过启动 Compute Emulator 并期待本地部署,确保您拥有端点
  • 在提供的 IP 和端口号上 telnet 以查看是否可以实际建立连接

验证端点 UI:

端点用户界面

好吧,这将向您显示输入端点。从我看到的情况来看,您正在使用内部端点。只是为了试用,尝试将它们更改为 Input 以查看行为是否会有一些变化。

但首先检查您是否已安装 WCF 激活。

于 2012-11-07T19:34:56.287 回答
0

当我忘记在我的开发盒上取消绑定 IIS(完整 IIS)中的默认网站时,我总是会遇到这个问题。你记得这样做吗?默认情况下,您的本地 IIS 会将 http 绑定到“默认网站”上的端口 80。如果您将该绑定(使用 inetmgr)编辑到另一个端口,则模拟器可以抓取 80。

于 2012-11-07T22:40:44.950 回答