gpt4 book ai didi

java - 无法从Java程序解析TestContainers网络别名

转载 作者:行者123 更新时间:2023-12-01 17:57:47 24 4
gpt4 key购买 nike

我有两个由TestContainers创建的容器。一个是S3 LocalStack容器,另一个是自定义容器(来自GenericContainer)。它们共享相同的网络(在创建它们时添加到它们)。我在LocalStack容器上有一个网络别名。当启动第二个自定义容器时,我可以运行container.execInContainer()以使用wget(以及别名和端口)连接到LocalStack容器。这个工作正常,我得到了预期的S3 XML响应(可以在下面的日志中看到)。因此,可以从第二个容器访问第一个容器。

在我的自定义容器中,我有一个Java应用程序,该应用程序使用Netty(通过Vertx)向我的S3容器发出HTTP请求。尽管失败,但带有UnknownHostException。因此,似乎我可以通过命令行上的wget连接到第二个容器,但不能从Java应用程序内部连接。我已经尝试获取LocalStack容器的网络IP并使用它代替网络别名,但这也不起作用。我还尝试过通过自定义容器上的container.withExtraHost将别名和LocalStack容器IP添加到自定义容器的主机文件中,但这也不起作用。连接到真实的S3端点时(不使用测试testcontainer时),该应用程序可以正常工作。

堆栈跟踪来自Netty(堆栈跟踪中没有对Vertx客户端的任何引用):

[DEBUG] e.u.library.iiif.fester.utils.ContainerUtils:59 | =====================================================>
[DEBUG] e.u.library.iiif.fester.utils.ContainerUtils:61 | Trying to access http://s3.localstack:4572
[DEBUG] e.u.library.iiif.fester.utils.ContainerUtils:65 | <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01"><Owner><ID>bcaf1ffd86f41161ca5fb16fd081034f</ID><DisplayName>webfile</DisplayName></Owner><Buckets></Buckets></ListAllMyBucketsResult>
[DEBUG] e.u.library.iiif.fester.utils.ContainerUtils:69 | <=====================================================
waiting... http://localhost:34784/bar/manifest
[INFO] FesterFT: | STDOUT: [ERROR] e.u.l.iiif.fester.handlers.GetManifestHandler:88 | failed to resolve 'http://s3.localstack:4572' after 2 queries
[INFO] FesterFT: | STDOUT: java.net.UnknownHostException: failed to resolve 'http://s3.localstack:4572' after 2 queries
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:925)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:884)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:356)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:543)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:64)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:400)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:570)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:549)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsQueryContext.setSuccess(DnsQueryContext.java:204)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:196)
[INFO] FesterFT: | STDOUT: at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1320)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
[INFO] FesterFT: | STDOUT: at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
[INFO] FesterFT: | STDOUT: at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
[INFO] FesterFT: | STDOUT: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
[INFO] FesterFT: | STDOUT: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931)
[INFO] FesterFT: | STDOUT: at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93)
[INFO] FesterFT: | STDOUT: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700)
[INFO] FesterFT: | STDOUT: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635)
[INFO] FesterFT: | STDOUT: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552)
[INFO] FesterFT: | STDOUT: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044)
[INFO] FesterFT: | STDOUT: at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
[INFO] FesterFT: | STDOUT: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[INFO] FesterFT: | STDOUT: at java.base/java.lang.Thread.run(Thread.java:834)


有人对出什么问题有任何想法吗?

最佳答案

好的,我做了一些愚蠢的事情,但是我想我会把它保留下来。现在,我正在使用具有默认Web端口以外的端口的S3端点,我相信我只需要以不同的方式初始化HTTP客户端的默认Web主机。可能应该是暗示要解决的问题并非严格是主机名(带有“ http://”和端口号)。无论如何,没有什么比问一个问题来帮助您自己找到解决方案了。我两天都不能接受,但是无论如何应该让我有时间确认。

关于java - 无法从Java程序解析TestContainers网络别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60686551/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com