c# - 套接字连接在 wcf 中中止

标签 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”。 "

有什么想法吗?

最佳答案

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

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

关于c# - 套接字连接在 wcf 中中止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16102707/

相关文章:

c# - 按数字的总和排序

c# - 使用 C# 将时间跨度值转换为格式 "hh:mm Am/Pm"

c# - 将套接字从 .NET 传递到非托管 C++ 代码

连接 : connection refused in c program at client side

c# - 继承 Controller 时无法让 Route 在 ASP.Net Web API 2 中工作

c# - 更改外部窗口的最小尺寸

c# - 试着捕获问题

c# - 如何在 WCF 服务中使用 RequestContext 映射路径

asp.net - Log4net threadContext 与 IIS 中托管的 WCF 一起使用是否安全?

node.js - Node js - 运行多个child_process,但某些请求意外关闭