套接字连接在wcf中被中止

时间:2013-04-19 10:37:31

标签: c# wcf sockets nettcpbinding

我在服务器端创建了动态端点,客户端使用了该端点。

服务器端代码:

 for (int i = 1; i <= 3; i++)
            {
                host.AddServiceEndpoint(typeof(PokerService.IPlayerService),
                                               new NetTcpBinding(),
                                               @"net.tcp://localhost:5054/player" + i);

            }

客户方:

NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);
binding.Name = "NetTcpBinding_IPlayerService";
binding.Security.Message.ClientCredentialType = MessageCredentialType.IssuedToken;


EndpointAddress myEndpointAdd = new EndpointAddress(new Uri("net.tcp://localhost:5054/player1"),
EndpointIdentity.CreateDnsIdentity("pident.cloudapp.net"));

var PlayerChannelFactory = new DuplexChannelFactory<ClientApplication.PlayerService.IPlayerService>(new PlayerHandler(handler, this), binding, myEndpointAdd);

但它在以下行中给出了错误:

Player loggedIn = PlayerServiceProxy.Login("testuser" + Guid.NewGuid().ToString());

错误是:

“套接字连接已中止。这可能是由于处理消息时出错或远程主机超出接收超时或基础网络资源问题引起的。本地套接字超时为'00:00:59.9870000'。 “

有什么想法?

1 个答案:

答案 0 :(得分:0)

好像超时了。查看您的客户端和服务超时配置。

另外,尝试使用svcTraceViewer.exe查看wcf trace