servicex-sh / httpx

httpx - CLI to test HTTP/gRPC/RSocket/Kafka... services by HTTP DSL
https://servicex.sh
Apache License 2.0
132 stars 9 forks source link

unknown host exception #2

Closed stijn-at-work closed 2 years ago

stijn-at-work commented 2 years ago

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 commented 2 years ago

httpx -x host:port is ok for you?

stijn-at-work commented 2 years ago

Yes, such a parameter would be great!

Op 9 apr. 2022 04:29 schreef Libing Chen @.***>:

httpx --proxy [protocol://]host[:port] is ok for you?

— Reply to this email directly, view it on GitHubhttps://github.com/servicex-sh/httpx/issues/2#issuecomment-1093601717, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIPZLA7TKPKXXLAZ2FJFJOLVEDTRHANCNFSM5SSCCYSA. You are receiving this because you authored the thread.Message ID: @.***>

linux-china commented 2 years ago

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

sbartram commented 2 years ago

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

linux-china commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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