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

unknown host exception #2

Closed
stijn-at-work opened this issue Apr 5, 2022 · 9 comments
Closed

unknown host exception #2

stijn-at-work opened this issue Apr 5, 2022 · 9 comments

Comments

@stijn-at-work
Copy link

stijn-at-work commented Apr 5, 2022

Hi!

i try to run auth.http from the command line:
httpx --httpfile auth.http

An exception is thrown (see below).

There is nothing wrong with the request. When i use Postman to POST https://lvapitest.localhost.wip/api/oauth/v2/token, i get a valid response with status code 200.

I think the problem is our proxy. We have set the proxy configuration at the system level (MacOs Big Sur) to:

automatic proxy configuration
proxy configuration file: http://127.0.0.1:7080/proxy.pac

Is it possible to add the proxy configuration to the command line arguments?

Regards, Stijn


auth.http

#!/usr/bin/env

### get tokens
POST https://{{env}}.{{domain}}/api/oauth/v2/token
Content-Type: application/json

{
    "grant_type": "password",
    "client_id": "{{client_id}}",
    "client_secret": "{{client_secret}}",
    "username": "{{username}}",
    "password": "{{password}}"
}

> {%
client.test('Post token', function() {
   client.assert(response.status === 200, 'Response status is not 200');
   client.assert(response.body.hasOwnProperty('access_token'), 'Response  bevat geen access_token');
   client.assert(response.body.hasOwnProperty('refresh_token'), 'Response  bevat geen refresh_token');
});

if (response.body.hasOwnProperty('access_token') && response.body.hasOwnProperty('refresh_token')) {
    client.global.set("accessToken", response.body['access_token']);
    client.global.set("refreshToken", response.body['refresh_token']);
}
%}

Exception

POST https://lvapitest.localhost.wip/api/oauth/v2/token

2022-04-05 10:51:04.366 ERROR 52922 --- [           main] org.mvnsearch.http.HttpxCommand          : HTX-002-500 - Failed to parse http code!

reactor.core.Exceptions$ReactiveException: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'lvapitest.localhost.wip' and search domain query for configured domains failed as well: [home]
	at reactor.core.Exceptions.propagate(Exceptions.java:392) ~[na:na]
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97) ~[na:na]
	at reactor.core.publisher.Mono.block(Mono.java:1707) ~[na:na]
	at org.mvnsearch.http.protocol.HttpBaseExecutor.request(HttpBaseExecutor.java:94) ~[na:na]
	at org.mvnsearch.http.protocol.HttpExecutor.execute(HttpExecutor.java:40) ~[na:na]
	at org.mvnsearch.http.HttpxCommand.execute(HttpxCommand.java:278) ~[httpx:0.23.0]
	at org.mvnsearch.http.HttpxCommand.call(HttpxCommand.java:201) ~[httpx:0.23.0]
	at org.mvnsearch.http.HttpxCommand.call(HttpxCommand.java:33) ~[httpx:0.23.0]
	at picocli.CommandLine.executeUserObject(CommandLine.java:1953) ~[na:na]
	at picocli.CommandLine.access$1300(CommandLine.java:145) ~[na:na]
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358) ~[na:na]
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2352) ~[na:na]
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2314) ~[na:na]
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) ~[na:na]
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2316) ~[na:na]
	at picocli.CommandLine.execute(CommandLine.java:2078) ~[na:na]
	at org.mvnsearch.http.HttpFileRunner.run(HttpFileRunner.java:24) ~[httpx:0.23.0]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:777) ~[httpx:0.23.0]
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:761) ~[httpx:0.23.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[httpx:0.23.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[httpx:0.23.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[httpx:0.23.0]
	at org.mvnsearch.http.HttpxApplication.main(HttpxApplication.java:23) ~[httpx:0.23.0]
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[na:na]
		... 21 common frames omitted
Caused by: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'lvapitest.localhost.wip' and search domain query for configured domains failed as well: [home]
	at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1047) ~[na:na]
	at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:1000) ~[na:na]
	at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:418) ~[na:na]
	at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:629) ~[na:na]
	at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:66) ~[na:na]
	at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:462) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605) ~[na:na]
	at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) ~[na:na]
	at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:216) ~[na:na]
	at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:208) ~[na:na]
	at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1314) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[na:na]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[na:na]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[na:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[na:na]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[na:na]
	at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97) ~[na:na]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) ~[na:na]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[na:na]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[na:na]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[na:na]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[na:na]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[na:na]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[na:na]
	at java.lang.Thread.run(Thread.java:833) ~[na:na]
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597) ~[na:na]
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:194) ~[na:na]
@linux-china
Copy link
Collaborator

linux-china commented Apr 9, 2022

httpx -x host:port is ok for you?

linux-china added a commit that referenced this issue Apr 9, 2022
@stijn-at-work
Copy link
Author

stijn-at-work commented Apr 9, 2022 via email

@linux-china
Copy link
Collaborator

Please try new 0.25.0 version. Let me know if it does not work.

@sbartram
Copy link

Is there a reason the program doesn't respect the http_proxy / https_proxy environment variables?

@linux-china
Copy link
Collaborator

Yes, it's some hard. JetBrains uses https://github.com/JetBrains/intellij-deps-proxy-vole to detect the platform network proxy settings.

respect the http_proxy / https_proxy environment variables

you means export HTTP_PROXY=http://SERVER:PORT/?

@sbartram
Copy link

Yes, it's some hard. JetBrains uses https://github.com/JetBrains/intellij-deps-proxy-vole to detect the platform network proxy settings.

respect the http_proxy / https_proxy environment variables

you means export HTTP_PROXY=http://SERVER:PORT/?

Yes.

@linux-china
Copy link
Collaborator

@sbartram You can use shebang for http file with proxy setting to make life easy.

#!/usr/bin/env httpx -x 192.168.1.1:3128 --httpfile

### get my internet ip
# @name myip
GET https://httpbin.org/ip

To make http file executable by chmod u+x demo.http, then execute ./demo.http myip

@sbartram
Copy link

Yeah, there are a couple of ways to workaround the issue. I just thought it would be a good feature to add so workarounds aren't required.

Thanks

@linux-china
Copy link
Collaborator

Implemented on 0.29.0 https://github.com/servicex-sh/httpx/releases/tag/v0.29.0

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

No branches or pull requests

3 participants