简体   繁体   English

连接到MongoDB服务集群时出错:SASL身份验证步骤上服务器返回错误:身份验证错误身份验证失败

[英]error connecting to MongoDB service cluster: server returned error on SASL authentication step: bad auth Authentication failed

I am trying to use the Stitch service by Mongodb. 我正在尝试使用Mongodb的Stitch服务。 When I try to connect to MongoDB, it gives me this error : 当我尝试连接到MongoDB时,它给了我这个错误:

Error while executing pipeline com.mongodb.stitch.android.StitchException$StitchServiceException: error connecting to MongoDB service cluster: server returned error on SASL authentication step: bad auth Authentication failed. 执行管道com.mongodb.stitch.android.StitchException $ StitchServiceException时发生错误:连接到MongoDB服务群集时出错:SASL身份验证步骤服务器返回错误:错误的身份验证身份验证失败。

I have already seen this question, but here he was using login and password for authentication but I'am using FacebookAuthProvider for login. 我已经看到了这个问题,但是在这里他使用登录名和密码进行身份验证,但是我正在使用FacebookAuthProvider进行登录。 So there shouldn't be any issue of bad auth , as I can clearly see the users Facebook data. 因此,不应该存在任何bad auth问题,因为我可以清楚地看到用户的Facebook数据。

This is the code I used for the same. 这是我用于相同的代码。

        stitchClient = new StitchClient(getApplicationContext(), "user-recognition-tgnek");
        mongoClient = new MongoClient(stitchClient, "mongodb-atlas");
        db = mongoClient.getDatabase("<DatabaseName>");

        FacebookAuthProvider fbProvider = FacebookAuthProvider.fromAccessToken(AccessToken.getCurrentAccessToken().getToken());
        stitchClient.logInWithProvider(fbProvider).continueWithTask(new Continuation<String, Task<Void>>() {
            @Override
            public Task<Void> then(@NonNull Task<String> task) throws Exception {
                final Document updateDoc = new Document(
                        "owner_id",
                        task.getResult()
                );
                updateDoc.put("Name", "Deepanshu Luhach");
                return db.getCollection("Users").updateOne(null, updateDoc, true);
            }
        }).continueWithTask(new Continuation<Void, Task<List<Document>>>() {
            @Override
            public Task<List<Document>> then(@NonNull Task<Void> task) throws Exception {
                if (!task.isSuccessful()) {
                    throw task.getException();
                }
                return db.getCollection("Users").find(
                        new Document("owner_id", stitchClient.getUserId()),
                        100
                );
            }
        }).addOnCompleteListener(new OnCompleteListener<List<Document>>() {
            @Override
            public void onComplete(@NonNull Task<List<Document>> task) {
                if (task.isSuccessful()) {
                    Log.d("STITCH", task.getResult().toString());
                    return;
                }
                Log.e("STITCH", task.getException().toString());
            }
        });

This is the complete Logcat: 这是完整的Logcat:

12-23 23:21:30.691 7086-7119/com.example.nwagh.myapplication E/Volley: [4067] BasicNetwork.performRequest: Unexpected response code 502 for https://stitch.mongodb.com/api/client/v1.0/app/user-recognition-tgnek/pipeline 12-23 23:21:30.705 7086-7086/com.example.nwagh.myapplication E/Stitch: Error while executing pipeline com.mongodb.stitch.android.StitchException$StitchServiceException: error connecting to MongoDB service cluster: server returned error on SASL authentication step: bad auth Authentication failed. 12-23 23:21:30.691 7086-7119 / com.example.nwagh.myapplication E / Volley:[4067] BasicNetwork.performRequest: https ://stitch.mongodb.com/api/client/v1的意外响应代码502 .0 / app / user-recognition-tgnek /管道 12-23 23:21:30.705 7086-7086 / com.example.nwagh.myapplication E / Stitch:执行管道com.mongodb.stitch.android.StitchException $ StitchServiceException时出错:连接到MongoDB服务集群时出错:SASL身份验证步骤中服务器返回错误:错误的身份验证身份验证失败。 at com.mongodb.stitch.android.StitchError.a(SourceFile:53) at com.mongodb.stitch.android.StitchClient$10.onErrorResponse(SourceFile:754) at com.android.volley.Request.deliverError(Request.java:598) at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:101) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6515) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 在com.mongodb.stitch.android.StitchError.a(SourceFile:53)在com.mongodb.stitch.android.StitchClient $ 10.onErrorResponse(SourceFile:754)在com.android.volley.Request.deliverError(Request.java: 598),位于com.android.volley.ExecutorDelivery $ ResponseDeliveryRunnable.run(ExecutorDelivery.java:101),位于android.os.Handler.handleCallback(Handler.java:790),位于android.os.Handler.dispatchMessage(Handler.java:99) ),位于com.android.java.lang.reflect.Method.invoke(本机方法)处android.app.ActivityThread.main(ActivityThread.java:6515)处android.os.Looper.loop(Looper.java:164)处。在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)上的internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:440)

Please help me with this issue, I can't find anything related to this. 请帮助我解决这个问题,我找不到与此相关的任何内容。

There was some error with connection to Atlas cluster . Atlas群集的连接存在一些错误。 Just try to relink the app with the cluster and everything will work perfectly. 只需尝试将应用程序与集群重新链接 ,一切将正常运行。

To relink your app go to MongoDB Atlas -> Stitch Apps -> In the Actions you will see the option to unlink the app, then you can relink it again. 要重新链接您的应用程序,请转到MongoDB Atlas- > Stitch Apps- >在“ 操作”中,您将看到取消链接该应用程序的选项,然后可以再次重新链接它。

Credits: @edaniels 积分: @edaniels

I had the same error when using with dokku mongo:import. 与dokku mongo:import一起使用时出现相同的错误。 I am suspecting that you included special characters in your mongo db name. 我怀疑您在mongo数据库名称中包含特殊字符。 In my case I included dot(period) in my db name 就我而言,我在数据库名称中包含了点号(句点)

You shouldn't include dot in your mongodb name when 'dokku mongo:create ' I've changed it to seunghunlee instead of seunghunlee.net now this command works 'dokku mongo:create'时,您不应该在mongodb名称中包含点号。我现在将其更改为seunghunlee而不是seunghunlee.net,此命令现在可以了

dokku mongo:import seunghunlee < seunghunlee.net.dump.gz

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM