Memcache服务器客户端中的错误 [英] Errors in Memcache server client

查看:554
本文介绍了Memcache服务器客户端中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试用Java编写一个简单的代码以连接到Memcache服务器.我使用的是spymemcached 2.8 jar,但我无法理解服务器重新连接错误.
代码是

Hi,
I m tryin to write a simple code in java to connect to memcache server . I using spymemcached 2.8 jar but i m getting server reconnecting error which i m unable to understand.
code is

client =  new MemcachedClient(new    BinaryConnectionFactory(),AddrUtil.getAddresses("127.0.0.1:11211"));
} catch (IOException e) {
   e.printStackTrace();
   System.err.println("connection problem");
}
 client.set("someKey", 3600, new Integer(10));
Object myObject=temp.client.get("someKey");
System.out.println(myObject);
client.delete("someKey");



但是我遇到了以下错误:



but i m getting errors which are:

2012-06-14 17:58:31.412 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-06-14 17:58:31.428 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@1621e42
2012-06-14 17:58:31.428 INFO net.spy.memcached.MemcachedConnection:  Reconnecting due to exception on {QA sa=/127.0.0.1:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1, topWop=null, toWrite=0, interested=1}
java.io.IOException: Disconnected unexpected, will reconnect.
	at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:452)
	at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:380)
	at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:242)
	at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:833)
2012-06-14 17:58:31.428 WARN net.spy.memcached.MemcachedConnection:  Closing, and reopening {QA sa=/127.0.0.1:11211, #Rops=1, #Wops=0, #iq=1, topRop=Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1, topWop=null, toWrite=0, interested=1}, attempt 0.
2012-06-14 17:58:31.428 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl:  Discarding partially completed op: Cmd: 1 Opaque: 1 Key: someKey Cas: 0 Exp: 3600 Flags: 512 Data Length: 1
2012-06-14 17:58:31.444 WARN net.spy.memcached.MemcachedConnection:  Could not redistribute to another node, retrying primary node for someKey.
2012-06-14 17:58:33.444 INFO net.spy.memcached.MemcachedConnection:  Reconnecting {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=1, #iq=0, topRop=null, topWop=Cmd: 0 Opaque: 3 Key: someKey, toWrite=0, interested=0}
2012-06-14 17:58:33.444 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@1813fac
Exception in thread "main" net.spy.memcached.OperationTimeoutException: Timeout waiting for value
	at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1003)
	at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1018)
	at ballydev.Memcache.main(Memcache.java:29)
Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: /127.0.0.1:11211
	at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:93)
	at net.spy.memcached.internal.GetFuture.get(GetFuture.java:62)
	at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:997)
	... 2 more



任何有任何想法或建议的人..请答复..



Anyone having any idea or suggestion .. please reply..

推荐答案

...我对memcached不熟悉-但我发现那里存在连接问题. br/>
您是保持与服务器的连接还是每次都建立新的连接?
...I''m not familiar with the memcached - but I see connection problems there.

Do you keep the connection to the server or do you make a new connection every time?


这里有一些带有有效示例的文档.请注意,根据您的部署,您可能不必担心身份验证.


https://devcenter.heroku.com/articles/memcachier#java [
Here''s some documentation with a working example. Note that you may not need to worry about authentication depending on your deployment.


https://devcenter.heroku.com/articles/memcachier#java[^]


感谢大家,
但事实证明,这是我的盒子[称为CPU]的问题,当它在其他服务器上运行时,它的工作方式像是奶酪....
再次感谢大家...

Thanks guys,
but as it turned out it was a problem of my box[called CPU] , when it ran it on different server it worked like cheese....
Thanks a lot again guys...

But since we are the topic, the reason behind this non working of memcached service on some system may be due to following reasons:
1. 11211 port (default port of memcached) may be blocked by your system Firewall.
2. Port is being used by some other service.
3.Service may not be started in your system.
4. Service is not compatible with your OS.(Memcached is generally used on *nix systems but they provide binaries for      windows also which i am using )


这篇关于Memcache服务器客户端中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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