【发布时间】:2012-08-30 14:38:02
【问题描述】:
a) 我有一个 WCF 服务,在 Windows 服务中自行托管,在 Windows 2008 R2 机器 A 上。它使用 net.tcp 绑定。不共享端口。
b) 我有一个在 Windows 2008 R2 机器 B 上的 IIS 上运行的 ASP.Net 网站(作为 ApplicationPoolIdentity,尽管我怀疑是否相关),它必须调用机器 A 上的服务。
我收到此错误:
System.ServiceModel.CommunicationException:套接字连接已中止。这可能是由于处理您的消息时出错或远程主机超出接收超时,或者是潜在的网络资源问题造成的。本地套接字超时为“00:01:00”。 ---> System.IO.IOException: 读操作失败,见内部异常。 ---> System.ServiceModel.CommunicationException:套接字连接被中止。这可能是由于处理您的消息时出错或远程主机超出接收超时,或者是潜在的网络资源问题造成的。本地套接字超时为“00:01:00”。 ---> System.Net.Sockets.SocketException: 现有连接被远程主机强行关闭 在 System.Net.Sockets.Socket.Receive(Byte[] 缓冲区,Int32 偏移量,Int32 大小,SocketFlags socketFlags) 在 System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时,布尔关闭) --- 内部异常堆栈跟踪结束 --- 在 System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时,布尔关闭) 在 System.ServiceModel.Channels.SocketConnection.Read(Byte[] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时) 在 System.ServiceModel.Channels.DelegatingConnection.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时) 在 System.ServiceModel.Channels.ConnectionStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 计数) 在 System.Net.FixedSizeReader.ReadPacket(字节 [] 缓冲区,Int32 偏移量,Int32 计数) 在 System.Net.Security.NegotiateStream.StartFrameHeader(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) 在 System.Net.Security.NegotiateStream.ProcessRead(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) --- 内部异常堆栈跟踪结束 --- 在 System.Net.Security.NegotiateStream.ProcessRead(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncProtocolRequest asyncRequest) 在 System.Net.Security.NegotiateStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 计数) 在 System.ServiceModel.Channels.StreamConnection.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时) --- 内部异常堆栈跟踪结束 ---
服务器堆栈跟踪: 在 System.ServiceModel.Channels.StreamConnection.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小,TimeSpan 超时) 在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection 连接,ArraySegment`1 前导码,TimeoutHelper 和 timeoutHelper) 在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection 连接,TimeoutHelper 和 timeoutHelper) 在 System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan 超时) 在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(时间跨度超时) 在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时) 在 System.ServiceModel.Channels.ServiceChannel.OnOpen(时间跨度超时) 在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时) 在 System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel 通道,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan 超时,CallOnceManager 级联) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime 操作) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)
这看起来像是连接/防火墙问题,但实际上并非如此:
c) 我做了一个简单的 winforms 应用程序,它使用与 (b) 完全相同的代码来调用机器 A 上的 WCF 服务。它在机器 B 上运行时成功。
(b) 和 (c) 都在代码中创建 WCF 代理,而不使用 web.config/app.config 中的任何内容。他们都为端点使用相同的 URI
所以在 IIS 进行 net.tcp 调用和常规应用程序之间一定有一些区别......?有什么与此相关的安全性吗?
为了以防万一,我已尝试启用通常需要在 IIS 中托管的所有 Windows 服务(WAS、网络适配器侦听器、端口共享...),但没有任何区别。
非常感谢您的意见。
【问题讨论】:
-
您好,您是否在 IIS 中的网站中添加了 tcp 协议和 tcp 绑定?非 HTTP 绑定需要 IIS 下的 WAS。
-
也许我不明白这一点,但只是检查一下 - 你明白 IIS 是客户端,而不是这个配置中的服务器吗?
-
哎呀,读得太快了。对不起。您是否尝试了另一个帐户的应用程序池?根据您的绑定,默认安全模式可以是 Windows。从 WebForm(使用您的帐户)运行与在 IIS 中托管不同。
-
谢谢,是的 - 更改为 SYSTEM 帐户 - 没有区别。
-
看起来很奇怪。我真的没有答案。也许您可以禁用将安全模式设置为无(以防万一)或更改您的绑定以进行测试。