使用C#客户端与WebSphere MQ断开连接时,TCP连接仍处于CLOSE_WAIT状态 [英] When disconnecting from WebSphere MQ with C# client TCP connections are still in CLOSE_WAIT status

查看:234
本文介绍了使用C#客户端与WebSphere MQ断开连接时,TCP连接仍处于CLOSE_WAIT状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码断开与MQQueue和MQQueueManager的连接:

I am disconnecting from MQQueue and MQQueueManager with the following code:


Queue.Close();
log.Info( "Queue IsOpen: " + Queue.IsOpen.ToString() );
Queue = null;

QueueManager.Disconnect();
QueueManager.Close();
log.Info( "QM IsOpen: " + QueueManager.IsOpen.ToString() );
log.Info( "QM IsConnected: " + QueueManager.IsConnected.ToString() );
QueueManager = null;

为此,我得到以下日志条目:

And I get the following log entries for this:


Queue IsOpen: false
QM IsOpen: false
QM IsConnected: false

但是几个小时后,当我从命令提示符运行 netstat -n 命令时,我得到了一长串与MQ服务器的连接,这些连接中的状态为 CLOSE_WAIT .

But after few hours when I run netstat -n command from command prompt I get a long list of connections to MQ server and the State in those connections is CLOSE_WAIT.

有什么想法为什么TCP连接没有完全关闭?有什么方法可以杀死我的代码吗?目前,我必须重新启动客户端应用程序,以清理打开的连接.

Any ideas why the TCP connections doesn't get fully closed? Are there any way that I could kill those from code? Currently I'll have to restart the client app which cleans up the open connections.

WebSphere MQ版本为6.0.2.6,.NET库来自MQ 7.

WebSphere MQ version is 6.0.2.6 and the .NET libraries are from MQ 7.

推荐答案

在《迁移指南》中,有一个名为 WebSphere MQ客户端配置文件.

Looking in the Migration Guide there's a section called Upgrading a WebSphere MQ client from Version 6.0 to Version 7.0 which suggests a possible explanation. It states that as of v7 the TCP tuning is stored in the client configuration file. So if you have enabled TCP Keepalive in the Windows registry, the v7 client will ignore it. The format and location of the file is described in WebSphere MQ client configuration file.

这当然是问题所在,必须有套接字泄漏.您没有提到您拥有哪个版本的WMQ V7客户端,但是Fix Pack README文件的确显示了许多与套接字泄漏,断开连接后无法清除等有关的APAR.这些都没有直接提到C#或.Net,但是围绕连接/断开连接问题存在足够的问题,值得进行升级.

Of course for this to be the problem, there has to be a socket leak. You did not mention which version of WMQ V7 client you have but the Fix Pack README files do show a number of APARs related to socket leaks, failure to clean up after disconnects and so forth. None of these directly mention C# or .Net but there are enough problems around connection/disconnection issues to make it worth an upgrade.

那么首先&尝试进行的最简单的修复是将TCP Keepalive添加到客户端配置文件,然后查看是否有帮助.当您在那里时,也请禁用连接共享.这不应该是一个因素,但是也不应该泄漏套接字.不会疼的接下来是应用修复Pack 7.0.1.2 (本文撰写时为最新),然后查看是否可以解决问题.在那之后,是PMR时间.希望有帮助.

So first & easiest fix to attempt is to add TCP Keepalive to the client configuration file and see if it helps. Disable connection sharing while you are in there as well. It's not supposed to be a factor but then it's not supposed to leak sockets either. Can't hurt. Next is to apply Fix Pack 7.0.1.2 (latest as of this writing) and see if that fixes the problem. After that, it's PMR time. Hope that helps.

这篇关于使用C#客户端与WebSphere MQ断开连接时,TCP连接仍处于CLOSE_WAIT状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆