Recent projects used in the membase found a problem, the production environment read and write all kinds of data are normal, but the new development environment, only the default bucket is not written data, call store always return false, the configuration file is identical, Really do not know where the problem, the other buckets are normal read and write, and, in the development environment of the membase on a new bucket is also normal read and write. Finally found the production on the Windows version of the Membase, and the development environment is the Linux (CentOS) version, suspected may be related to the server version, so installed a version of Windows, sure enough, everything is OK. As for the Linux version (couchbase) Why this problem, still have to spend time to find out why.
Project use of Dll:membase.dll 2.14.0.0,enyim.caching.dll 2.11.0.0, anti-compilation can see the code, but not good debugging, you can find the appropriate source code on the Internet:
- Https://github.com/enyim/EnyimMemcached
- Https://github.com/xianrendzw/LightFramework.Net
The second is to put Membase source package in the Lightframework.caching project, I am that code to check the reason.
Since the store failed, let's step through and see where the default bucket and other buckets are different in the store method.
Public BOOL string Object value) { ulong0; return This 0 ref tmp);}
You can see that the actual call is the Performstore method, followed by the discovery of var node = this.pool.Locate (Hashedkey), will return null, that is, no corresponding bucket is found, then what data ah.
Check why the return is NULL, we found that when initializing the membaseclient instance, we need to get the bucket information to the registered ServerURL (whether it is legitimate, the state is normal, etc.), call the Resolvebucket method, the result is abnormal. 401 error, not authorized!
When we initialized with other buckets, we found that the credential in the client parameter of the method is a value (username, password), and the default bucket is null. This should be the cause. Manually set the credential username to default, request the bucket verification information again, and sure enough, it returns correctly.
Wonder, not the default defaults can not set the password, how do we need to verify it? Google-related issues, found that many people do not know how to break, and even said that the Membase bug:
- Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url
- https://issues.couchbase.com/browse/MB-2166
- Http://qnalist.com/questions/5796245/membase-client-401-getting-config-from-pool-url
- Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url
In the process of finding the problem, I found that if the bucket is default, Membase.dll will empty its bucketname and password, meaning that it does not require authentication, go to the special port 11210 (the other bucket walk is 11211 authentication), since the comments are so, that is the request for wool in the bucket authentication information also need authentication?
The problem that default cannot write is caused by the above reasons, for the Windows version of Membase Server does not exist, I have tested, there is no authentication limit for the default bucket. And for the Linux version, through the source tracking process, the authentication information is manually modified, but also can read and write, but unfortunately, can not initialize the external membaseclient when the credential configuration is correct. There is another solution that uses memcachedclient because Membase is compatible with the Memcached SDK, so you can initialize the operation instance as follows:
var New memcachedclientconfiguration (); config. Addserver ("192.168.1.12",11211); var New memcachedclient (config); client. Store (Storemode.set, DateTime.Now.ToString ("hhmmss" ) TestValue");
It is also normal to read and write the default bucket in this way.
Problem analysis of Linux version membase unable to write to default bucket