mongodb-labs/mongo-rust-driver-prototype

Authentication failure when using with actix-web

Frederick888 opened this issue · 2 comments

Hi,

I tried to use this library with actix-web but I've got some troubles with authentication. I suspect that it's somehow related to the connection pool since it was alright if when I tested with curl, however the moment I fire up a wrk, even with some modest settings, it starts to throw numerous authentication errors.

I've pushed an example to https://github.com/Frederick888/actix-mongodb. TL;DR I used an OneCell to hold a shared client and in controllers I try db.auth() every time.

$ cat wrk.lua
function response(status, headers, body)
   print(body)
end
$ wrk -t 2 -c 4 -d 30s -s ./wrk.lua http://localhost:8080/items
# sometimes successful, but mostly erroneous
database error: Authentication failed.
database error: No SASL session state found

And it turned out if I simply ignore the authentication errors and proceed, there will be much more successful responses, but on the other hand it generates a lot of [{"$err":"not authorized for query on mydb.items","code":13,"ok":0.0}] this time.

Should I actually just instantiate a new client every time upon each request in the controller? Please shed some light on me, thanks.

saghm commented

Hello everyone! We've just released an alpha of an official MongoDB Rust driver; you can read about it here! Because of this, we won't be updating this driver anymore, and the repository will be made read-only as soon as I get finished posting these messages. Thanks for using this driver, and we hope you try out the new one!