killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 280 forks source link

unable to GET value from memcached which is set by C# client #70

Closed Jason-Gew closed 6 years ago

Jason-Gew commented 6 years ago

Hi,

I encountered an weird issue that Xmemcached client is not able to get value (String) from memcached which is set by C# Enyim client. However, the value can be access and read from terminal telnet, Python memcache client. Please let me know if you have any suggestions to solve this problem. Thanks!

2018-01-11 11:08:06.655 [ERROR] [main] BaseSerializingTranscoder: Failed to decompress data java.util.zip.ZipException: Not in GZIP format at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165) ~[?:1.8.0_144] at java.util.zip.GZIPInputStream.(GZIPInputStream.java:79) ~[?:1.8.0_144] at java.util.zip.GZIPInputStream.(GZIPInputStream.java:91) ~[?:1.8.0_144] at net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder.gzipDecompress(BaseSerializingTranscoder.java:274) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder.decompress(BaseSerializingTranscoder.java:219) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.transcoders.SerializingTranscoder.decode(SerializingTranscoder.java:87) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.XMemcachedClient.fetch0(XMemcachedClient.java:657) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.XMemcachedClient.get0(XMemcachedClient.java:1085) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1043) [xmemcached-2.4.0.jar:?] at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1065) [xmemcached-2.4.0.jar:?]

killme2008 commented 6 years ago

It seems that Enyim client set flag that means gzip compressed data in xmemcached, so xmemcached try to decompress the data,but it fails.

Maybe you have to implement a custom Transcoder for deserialization. Or you can try StringTranscoder:

 String name = client.get("hello", new StringTranscoder());
Jason-Gew commented 6 years ago

@killme2008 OK, I used StringTranscoder(), however, it generates Decode String error. Exception in thread "main" java.lang.RuntimeException: Decode String error at net.rubyeye.xmemcached.transcoders.StringTranscoder.decode(StringTranscoder.java:35) at net.rubyeye.xmemcached.transcoders.StringTranscoder.decode(StringTranscoder.java:11) at net.rubyeye.xmemcached.XMemcachedClient.fetch0(XMemcachedClient.java:657) at net.rubyeye.xmemcached.XMemcachedClient.get0(XMemcachedClient.java:1085) at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1043) at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1065)

In order to create my own Transcoder, have to research deep in C# Enyim client libraries? I wonder how terminal telnet and Python memcache client have no issue in read.

Jason-Gew commented 6 years ago

Hi,

So my last question is if we create our own Transcoder, in where we can ignore the flag that mean gzip was set by C# Enyim?

killme2008 commented 6 years ago

hi, you can see the StringTranscoder code

https://github.com/killme2008/xmemcached/blob/master/src/main/java/net/rubyeye/xmemcached/transcoders/StringTranscoder.java

Just remove the if condition test on flag

https://github.com/killme2008/xmemcached/blob/master/src/main/java/net/rubyeye/xmemcached/transcoders/StringTranscoder.java#L24

Jason-Gew commented 6 years ago

Hi Dennis,

Very Appreciate for your help! It solved our problem here!

Thanks!