无法连接到 java 中的本地 dynamo-db 实例

Unable to connect to local dynamo-db instance in java

我正在测试使用 dynamoDB 的应用程序。我已经使用 docker 在本地启动了一个实例,并且我能够在该实例中创建/添加项目。

现在,在我的 Java 应用程序中,我正在尝试连接到我的本地,当我发送一个 API 调用与我的本地 Dynamo 交互时,它抛出一个错误 -

Unable to execute HTTP request: Unsupported or unrecognised SSL message

我已经使用命令验证了端点和区域。 Java 连接 dynamo 的代码片段 -

AmazonDynamoDBClientBuilder builder = AmazonDynamoDBClientBuilder.standard().withCredentials(amazonAWSCredentialsProvider());
    if (StringUtils.isEmpty(endpoint))
        builder.withRegion(Regions.fromName(awsRegion));
    else
        builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, awsRegion));
    return builder.build();

我不确定这是哪里失败了。我正在为访问和密钥传递空白,区域是 aws configure get region 的输出。终结点配置为 localhost:8000.

堆栈跟踪 -

2021-10-26 17:44:35 [991c4652-5f7f-42ca-8aeb-447b385c535f] ERROR [http-nio-8085-exec-3] o.a.c.c.C.[.[.[.[dispatcherServlet] [DirectJDKLog.java:175] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported or unrecognized SSL message] with root cause javax.net.ssl.SSLException: Unsupported or unrecognized SSL message at sun.security.ssl.SSLSocketInputRecord.handleUnknownRecord(SSLSocketInputRecord.java:448) at sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:184) at sun.security.ssl.SSLTransport.decode(SSLTransport.java:109) at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1383) at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1291) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:435) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:436) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384) at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.connectSocket(SdkTLSSocketFactory.java:142) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)

我也无法连接到 http://localhost:8000/shell,尽管我的实例是 运行。

我成功了。我没有注意我用的url,我应该用http://localhost:8000(加上http://)而不是纯粹的localhost:8000。 愚蠢的错误会占用你很多时间!!