|
We are seeing connections very commonly re-authenticate with the same credentials on the same connection. We've replicated the problem with the simple test driver below. Tracing through the code a bit, it looks like the DB auths first (in DB.authenticate() below) and then the DBPort does it again when it's finally used (in DBCursor.toArray() below).
import com.mongodb.DB;
|
import com.mongodb.MongoURI;
|
|
public class AuthTest {
|
|
public static final String MONGO_URI = "mongodb://username:password@localhost/database";
|
|
public static void main ( String[] args ) {
|
try {
|
MongoURI uri = new MongoURI(MONGO_URI);
|
DB db = uri.connectDB();
|
db.authenticate(uri.getUsername(), uri.getPassword());
|
db.getCollection("collection").find().toArray();
|
} catch ( Exception e ) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|
Here's an example from the mongodb.log that shows the re-auth from a run of the test driver.
Sat May 26 18:53:27 [initandlisten] connection accepted from 192.168.1.90:56497 #63
|
Sat May 26 18:53:27 [conn63] authenticate: { authenticate: 1, user: "username", nonce: "a7ff424cc52c3fb9", key: "d520523babbc8fc133feec681409d77f" }
|
Sat May 26 18:53:27 [conn63] authenticate: { authenticate: 1, user: "username", nonce: "6b31c591ff203471", key: "cb243f059038af803511683c87b26e06" }
|
Sat May 26 18:53:28 [conn63] end connection 192.168.1.90:56497
|
|