NotSslRecordException:不是SSL / TLS记录

时间:2019-07-11 20:05:32

标签: java spring-data netty amazon-elasticache lettuce

我将Redt Spring Data(1.8.9.RELEASE)与生菜(4.5.0.Final)用作底层Redis驱动程序。它使用的是4.1.29版的netty。

我们正在使用Redis ElastiCache并启用了加密传输和静态加密。

我遇到了错误。我看到了与netty的NotSslRecordException相关的帖子,其中suggested cause与http和https不匹配。但是我们通过tcp与弹性痛联系。

Caused by: com.lambdaworks.redis.RedisException: com.lambdaworks.redis.RedisConnectionException: Unable to connect to xxx-redis-xxx-0002-002.-redis-xxx.usw2.cache.amazonaws.com:6379
    at com.lambdaworks.redis.LettuceFutures.await(LettuceFutures.java:130)
    at com.lambdaworks.redis.LettuceFutures.awaitOrCancel(LettuceFutures.java:96)
    at com.lambdaworks.redis.cluster.ClusterFutureSyncInvocationHandler.handleInvocation(ClusterFutureSyncInvocationHandler.java:117)
    at com.lambdaworks.redis.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
    at com.sun.proxy.$Proxy344.hgetall(Unknown Source)
    at org.springframework.data.redis.connection.lettuce.LettuceConnection.hGetAll(LettuceConnection.java:2887)
    ... 53 more
Caused by: com.lambdaworks.redis.RedisConnectionException: Unable to connect to qbo-pprd-redis-rpg-0002-002.qbo-pprd-redis-rpg.jtrqdt.usw2.cache.amazonaws.com:6379
    at com.lambdaworks.redis.RedisConnectionException.create(RedisConnectionException.java:56)
    at com.lambdaworks.redis.cluster.PooledClusterConnectionProvider.lambda$getConnectionAsync$7(PooledClusterConnectionProvider.java:344)
    at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822)
    at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
    at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
    at com.lambdaworks.redis.AbstractRedisClient.lambda$null$0(AbstractRedisClient.java:331)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
    at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
    at com.lambdaworks.redis.SslConnectionBuilder$SslChannelInitializer$2.userEventTriggered(SslConnectionBuilder.java:212)
    at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329)
    at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315)
    at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307)
    at io.netty.handler.ssl.SslUtils.handleHandshakeFailure(SslUtils.java:319)
    at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1573)
    at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1542)
    at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1183)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1243)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    ... 1 more
Caused by: java.util.concurrent.CompletionException: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 17000000242d455252206d6178206e756d626572206f6620636c69656e747320726561636865640d0a15000000020100
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
    ... 38 more
Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 17000000242d455252206d6178206e756d626572206f6620636c69656e747320726561636865640d0a15000000020100    

2 个答案:

答案 0 :(得分:4)

$ printf '17000000242d455252206d6178206e756d626572206f6620636c69656e747320726561636865640d0a15000000020100' | xxd -r -p | xxd
00000000: 1700 0000 242d 4552 5220 6d61 7820 6e75  ....$-ERR max nu
00000010: 6d62 6572 206f 6620 636c 6965 6e74 7320  mber of clients 
00000020: 7265 6163 6865 640d 0a15 0000 0002 0100  reached.........

答案 1 :(得分:0)

从线程堆栈看,您似乎正在将Spring Data Redis与Lettuce库结合使用。

在创建LettuceClientConfiguration时,您需要通过设置useSSL()选项来告诉Client使用SSL。 https://docs.spring.io/spring-data/redis/docs/current/api/org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration.html#isUseSsl--

我希望这会有所帮助。