我正在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已停用,不是问题。
这不是那么重要但重要的是我从我的interrole通信请求中得到了更严重的错误,尽管我完全禁用了防火墙。这是:
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:重要更新:
我认为问题在于第二个例子。我做了一个调试,我看到连接只被这个停止的实例拒绝了。我认为这解释了一切,但我不知道为什么会这样。
编辑2:临时解决方案:
我注意到这不是关于Windows 8的问题,因为我将Azure SDK 2012年6月SP1升级到2012年秋季。我从TFS下载了我的项目的未升级版本,而不是我看到它正在运行。总之,它是Azure SDK,但我不知道为什么。
答案 0 :(得分:2)
重新映射端口号根本不是问题的症状。这是正常行为,一直都是。 在进行/配置Windows 8开发盒时,您是否安装了“Windows功能”WCF激活:
测试您的服务是否实际启动并运行的另一种方法是:
验证端点UI:
好吧,这将显示输入端点。从我看到你正在使用内部端点。只是为了试用,尝试将它们更改为输入以查看行为是否会有一些变化。
但首先请检查您是否安装了WCF激活。
答案 1 :(得分:0)
当我忘记在我的开发框中取消绑定IIS(完整IIS)中的默认网站时,我总是遇到此问题。你记得那样做过吗?默认情况下,本地IIS将http绑定到“默认网站”上的端口80。如果您将该绑定(使用inetmgr)编辑到另一个端口,则模拟器可以获取80。