MongoCommandException:命令失败,错误8000(AtlasError):“未发送SNI名称,请确保使用MongoDB 3.4+驱动程序/ shell。” [英] MongoCommandException: Command failed with error 8000 (AtlasError): 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.'

查看:109
本文介绍了MongoCommandException:命令失败,错误8000(AtlasError):“未发送SNI名称,请确保使用MongoDB 3.4+驱动程序/ shell。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Java 11(Maven项目)用于mongodb Free Tier Cluster(版本4.0.13)。我正在尝试通过连接字符串(对于3.6驱动程序或更高版本)进行连接,例如:

I'm using Java 11 (Maven project) for mongodb Free Tier Cluster (Version 4.0.13). I'm trying to connect via connection-string (for 3.6 drivers or later) like:

mongodb+srv://user:pass@cluster0-ox90k.mongodb.net/test?retryWrites=true&w=majority

通过连接字符串以相同的方式(对于3.4驱动程序或更高版本):

and by the same way via connection-string (for 3.4 driver or later):

mongodb://user:pass@cluster0-shard-00-00-ox90k.mongodb.net:27017,cluster0-shard-00-01-ox90k.mongodb.net:27017,cluster0-shard-00-02-ox90k.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true&w=majority

我已经为Java驱动程序测试了不同的依赖项,例如:mongodb-driver-sync(3.1.1版),mongodb-driver-sync(3.10.0版),mongodb-driver-sync(3.8.0版) 。

I've already tested different dependencies for java drivers like: mongodb-driver-sync (ver. 3.11.0), mongodb-driver-sync (ver. 3.10.0) , mongodb-driver-sync (ver. 3.8.0).

Maven依赖性如下:

Maven dependency looks like this:

 <dependency>
      <groupId>org.mongodb</groupId>
      <artifactId>mongodb-driver-sync</artifactId>
      <version>3.11.0</version>
 </dependency>

我也尝试使用 mongo-java-driver 通过 3.6或更高版本的驱动程序/3.4或更高版本的连接字符串以及类似的版本:3.11.0、3.10.0、3.8.0、3.7.0。

Also I tried to use mongo-java-driver via connection-string for 3.6 or later drivers/3.4 or later and versions like: 3.11.0, 3.10.0, 3.8.0, 3.7.0.

Maven依赖性如下:

Maven dependency looks like this:

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.11.0</version>
</dependency>

我总是遇到同样的问题:

And I'm getting always the same issue:

Exception in thread "main" com.mongodb.MongoCommandException: Command failed with error 8000: 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.' on server cluster0-shard-00-01-ox90k.mongodb.net:27017. The full response is { "ok" : 0, "errmsg" : "no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.", "code" : 8000, "codeName" : "AtlasError" }
    at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:164)
    at com.mongodb.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:286)
    at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:247)
    at com.mongodb.connection.CommandHelper.sendAndReceive(CommandHelper.java:84)
    at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:34)
    at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:91)
    at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:51)

我当前的POM是:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test</groupId>
    <artifactId>test_project</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <!-- jsoup HTML parser library @ https://jsoup.org/ -->
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.11.0</version>
        </dependency>   
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>    
                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>project.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

任何解决问题的想法都会受到赞赏。

Any ideas how to solve the issue will be appreciated.

推荐答案

Java 8

我已将Java 11更改为Java 8,解决了这个问题。看起来 Java 11 不支持 SNI 。因为尽管我使用了最新的驱动程序,但所有尝试均未成功。

I've changed Java 11 to Java 8 and it solved the issue. Looks like Java 11 doesn't support SNI. Because all attempts were unsuccessful despite the fact that I used the latest drivers.

Java 11

感谢Virg的说明,我更改了Java 11的版本,也更改了许可证。我使用构建了Java开发工具包(来自Oracle)- 。然后,我以 Azulu 使用JDK版本11.0.5 + 10,它也解决了该错误。

Thanks to clarification by Virg, I've changed version of Java 11, but also the license. I had Java 11 using Java Development Kit builds (from Oracle) - as sourse. Then I've installed another license as Azulu using JDK version 11.0.5+10 and it also solved the error.

这篇关于MongoCommandException:命令失败,错误8000(AtlasError):“未发送SNI名称,请确保使用MongoDB 3.4+驱动程序/ shell。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆