大家好,
现在我使用mongo作为我的数据库。我发现我的mongo连接有时会自动重置或失败。然后我在我的mongo日志文件中发现了一些奇怪的消息,即
auth: bad nonce received or getnonce not called. could be a driver bug or a security attack. db:User
我用谷歌搜索了,但似乎很少有用户解决了这个问题,我只在github中找到了链接 https://github.com/mongodb/mongo/blob/master/db/security_commands的源代码的.cpp 的。从代码中,客户端将 user_name,use_password,nonce 发送到服务器进行身份验证,日志消息是由客户端发送并由服务器分发的nonce之间的差异引起的。
我的mongo驱动程序有什么问题吗?有人遇到过这个问题吗?
答案 0 :(得分:1)
当我使用mongodb-2.0.2和java-driver2.7.3时,我也遇到了这个错误。
它是用于开发的单个mongodb服务器,其中--auth
选项已打开。
我理解这是由多线程中的身份验证引起的:
DB db = m.getDB(dbName);
if(!db.isAuthenticated())
{
boolean pass = db.authenticate(name, pwd.toCharArray());
if(!pass)
throw new Exception("User " + name + " authentication failed for db " + dbName + "!");
}
在服务器端,在完成一个auth请求之前,另一个线程发送了一个新请求,导致第一个请求被覆盖。
将synchronized
添加到此方法后,它再也不会出现了。