【发布时间】:2011-11-13 15:53:11
【问题描述】:
我已经在 tomcat 容器中部署了我的 web 应用程序,但由于可能的连接泄漏,web 应用程序不断尝试连接到在端口 11211 和 11212 侦听的本地 memcached 服务器。我正在使用 spy-memcached客户。
我定义了一个 ContextListener,它基本上会关闭所有活动的 memcached 客户端连接。
但是,当我取消部署我的网络应用程序时,在我看来,tomcat 仍在尝试继续尝试连接到 memcached 服务器的失败尝试,但它不应该这样做。我已经检查了 memcached 服务器上的活动 tcp 连接使用netstat 但我找不到任何条目。
我也重新启动了tomcat服务器,但无济于事。
我应该如何限制 tomcat 建立这些连接?
2011-11-13 21:21:34.575 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11212, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:407)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:275)
at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:2030)
2011-11-13 21:21:34.576 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=localhost/127.0.0.1:11212, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}, attempt 32.
【问题讨论】:
-
重新连接尝试是否会导致问题?这是一个需要解决的问题吗?
-
它们本身并没有造成任何问题,但它们只是悬空重新连接,这让我很困扰,因为它填满了我的整个日志空间。我不知何故到了必须手动终止从端口 8080 到端口 11211 和 11212 的所有传入连接的地步,我认为这对我来说已经解决了。但是我仍然不明白为什么即使在上下文被破坏后陈旧的连接仍然存在??
-
我遇到了同样的问题,环境是 spymemcached 2.8.1,tomcat 6 on linux 2.6.18.2-34-default。 MemcachedClient 关闭在 ServletContextListener 的 contextDestroyed 中调用。奇怪的是错误消息说: 2012-06-28 11:00:39.753 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=0 , #iq=0, topRop=null, topWop=null, toWrite=0, Interest=0} 但是我曾经在我的应用程序中使用过端口 11212,不知何故它默认为 11211...
-
我认为 spymemcached 组的这个帖子描述了同样的问题。 groups.google.com/d/topic/spymemcached/lMpHWENfKEE/discussion 但是设置守护进程和调用关机并没有帮助。
标签: java tomcat memcached spymemcached