Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContainerGebSpec.download* methods fails with UnknownHostException #72

Open
matrei opened this issue Nov 8, 2024 · 1 comment · May be fixed by #74
Open

ContainerGebSpec.download* methods fails with UnknownHostException #72

matrei opened this issue Nov 8, 2024 · 1 comment · May be fixed by #74

Comments

@matrei
Copy link
Contributor

matrei commented Nov 8, 2024

Caused by: java.net.UnknownHostException: host.testcontainers.internal
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:572)
	at java.base/java.net.Socket.connect(Socket.java:633)
	at java.base/java.net.Socket.connect(Socket.java:583)
	at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:533)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:638)
	at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:281)
	at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:386)
	at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:408)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1323)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1256)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1142)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1071)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1701)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
	at geb.download.DefaultDownloadSupport.downloadStream_closure1(DefaultDownloadSupport.groovy:73)
	at geb.download.DefaultDownloadSupport.wrapInDownloadException(DefaultDownloadSupport.groovy:221)
	... 3 more
@matrei
Copy link
Contributor Author

matrei commented Nov 11, 2024

The reason for this is that the connections from the download*() methods are not made from within the container. They are made from the host system.

You can override the base and uri directly when invoking the method, to make it work:

downloadBytes([base: "http://localhost:$serverPort", uri: '/json/index'])

However, this is not the best user experience.

I have not yet found a way to switch out the default DownloadSupport implementation DefaultDownloadSupport, to another implementation that resolves the URI:s correctly when using ContainerGebSpec.

matrei added a commit that referenced this issue Nov 11, 2024
There must be a more elegant way to solve this, but this seems to work.

Resolves gh-72
matrei added a commit that referenced this issue Nov 11, 2024
There must be a more elegant way to solve this, but this seems to work.

Resolves gh-72
@matrei matrei linked a pull request Nov 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant