Hi,
I use .NET WEB API for working with couchbase Enterprise Edition 6.0.1.
I use Swagger for my test, and the method GetUser(string id) it is OK, it return a User.
BUT, GetAllUser doest’n work, I have this exception:
Couchbase.Linq.CouchbaseQueryException: ‘An error occurred executing the N1QL query. See the inner exception for details.’
SocketException: A connection attempt failed because the connected party did not respond properly beyond a certain time or an
established connection failed because the connection host did not respond 52.166.184.59:8093
In the Application_Start(), I put this code
ClusterHelper.Initialize(new ClientConfiguration
{
Servers = new List { new Uri(http://xx.xxx.xxx.xx:8091/") }
}, new PasswordAuthenticator(“xxxxxx”, “xxxxxx”));
And in the repository:
private readonly IBucket _bucket;
private readonly IBucketContext _context;
public UserRepository(IBucket bucket, IBucketContext context)
{
_bucket = ClusterHelper.GetBucket(“mybucket”);
_context = new BucketContext(_bucket);
}
public List GetAllUsers()
{
return _context.Query()
.ScanConsistency(ScanConsistency.RequestPlus)
.OrderBy(p => p.Username)
.ToList();
}
public User GetUser(string id)
{
var result = _bucket.Get(id);
if (!result.Success && result.Exception != null)
{
throw result.Exception;
}
return result.Value;
}