日期:2014-05-17  浏览次数:21173 次

WCF NetTcpBinding 外网连接不上
wcf服务在内网是能够正常访问的,并且,外网服务器的端口也开了。
 
把服务放在外网就连接不上,服务端和客户端的SecurityMode都为None,以下是抛出的异常,求帮助,各种求,囧...

Server stack trace: 
  在 System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
  在 System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
  在 System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
  在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
  在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  在 System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
  在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
  在 System.ServiceModel.Channels.CommunicationObject.Open()
 
 Exception rethrown at [0]: 
  在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
  在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
  在 System.ServiceModel.ICommunicationObject.Open()
  在 Castle.Facilities.WcfIntegration.WcfClientActivator.<>c__DisplayClass4.<GetChannelCreator>b__1()
  在 Castle.Facilities.WcfIntegration.WcfChannelHolder.CreateChannel()
  在 Castle.Facilities.WcfIntegration.WcfChannelHolder..ctor(ChannelCreator channelCreator, IWcfBurden burden, Nullable`1 closeTimeout)
  在 Castle.Facilities.WcfIntegration.WcfClientActivator.Instantiate(CreationContext context)
  在 Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
  在 Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context)
  在 Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context)
  在 Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context)
  在 Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired)
  在 Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context, Boolean instanceRequired)
  在 Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
  在 Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments)
  在 Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service)
  在 Castle.MicroKernel.DefaultKernel.Resolve(Type service)
  在 Castle.Windsor.WindsorContainer.Resolve[T]()

------解决方案--------------------
关键 nettcpbinding 是双工通道,服务端和客户端应该都在外网上。
------解决方案--------------------
果然这个错还是出在端口上面了,因为用的别人的云服务器,要使用端口需要申请开通。不好意思,误导大家了。