【发布时间】:2020-09-14 08:32:25
【问题描述】:
我在 Windows Server 2019 上继承了由 IIS 托管的 C# Web 服务,该服务遇到了我正在努力追查的问题。
WCF 服务在端口 82 上侦听 http 连接,在端口 8002 上侦听 net tcp 连接;该站点的 IIS 配置将其绑定设置为 http:*:82:,net.tcp:8002:*
但是,当服务运行几个小时后,它会停止在 net tcp 端口 (8002) 上响应 - 尝试连接到它的其他应用程序最终会超时:
System.TimeoutException: The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The socket transfer timed out after 00:01:00. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
但与 http 端口 (82) 的连接仍按预期工作,因此服务仍在运行。
回收适当的应用程序池会导致 net tcp 连接再次开始正常工作,这对我来说可能是某种资源泄漏,但我在代码中看不到任何明显的东西,而且似乎没有是内存不足。
我不知道如何进一步解决这个问题 - 有什么建议吗?
【问题讨论】:
-
永远不要使用低于 1000 的端口号,它们是为标准协议保留的,并且经常被病毒检查程序阻止。 Sop 将端口号从 82 更改为不同的数字。要从 cmd.exe 调试问题,请使用 >Netstat -a(在客户端和服务器上运行),它将给出每个端口的连接状态。服务器必须正在侦听端口。从客户端到服务器的连接也必须完全关闭,才能从相同的客户端 IP 建立新连接。通常这样的情况是由于旧连接永远不会关闭。
-
docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/… 您可能会从跟踪中获得一些初步想法,但挂起转储分析或分析器可能会更快(但需要技能)。
标签: c# wcf iis network-programming