Hi Team,

I have a perl script deployed on IIS server. When accessing this perl
script we are getting *Connection closed* error (see below for stack trace)
from Async HTTPClient 5.2.x future callback. When further debugged found
that IIS is sending “Connection: Close” header after the response is sent
due to which http client is throwing the said error even after reading /
processing the response. This is resulting in response lost what IIS has
sent. When I access the same resource using browser it is able to display
the content. Is there any mechanism to handle these kind of responses?



*Async HTTPClient Code*

Future<Message<HttpResponse, String>> responseHandler =
httpAsyncClient.execute(reqBuilder.build(),

                    new BasicResponseConsumer<>(new
AbstractClassicEntityConsumer<String>(){…}, null, clientContext, null);

*Message<HttpResponse, String> response = responseHandler.get();*

 retCode = response.getHead().getCode();



*Stack Trace / Exception stack*

org.apache.hc.core5.http.ConnectionClosedException: Connection is closed

               at
org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.disconnected(ClientHttp1StreamDuplexer.java:212)

               at
org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onDisconnect(AbstractHttp1StreamDuplexer.java:409)

               at
org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.disconnected(AbstractHttp1IOEventHandler.java:95)

               at
org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.disconnected(ClientHttp1IOEventHandler.java:41)

               at
org.apache.hc.client5.http.impl.async.LoggingIOSession$1.disconnected(LoggingIOSession.java:258)

               at
org.apache.hc.core5.reactor.InternalDataChannel.disconnected(InternalDataChannel.java:204)

               at
org.apache.hc.core5.reactor.SingleCoreIOReactor.processClosedSessions(SingleCoreIOReactor.java:231)

               at
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:133)

               at
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86)

               at
org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)

               at java.lang.Thread.run(Thread.java:748)





*HTTPClient log extract*

2023-02-21 15:37:59,600 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003 send request GET /sample/ldapUD/16239/printenv.pl HTTP/1.1,
entity len 0

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> GET /printenv.pl HTTP/1.1

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Accept-Encoding: gzip, deflate

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> SMSDOMAIN: .abc.net

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Cache-Control: max-age=0

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Upgrade-Insecure-Requests: 1

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> *connection: keep-alive*

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Accept-Language: en-US,en;q=0.9

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Content-Length: 0

2023-02-21 15:37:59,600 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 >> Host: iisserver

2023-02-21 15:37:59,600 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003: produce request data

….

….

….

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.wire]
c-0000000002[ACTIVE][r:r] << 7N. .s..c...      37 4e fe 1f e3 73 1b a9 63
10 00 00

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << HTTP/1.1 200 OK

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Content-Type: text/plain; charset=iso-8859-1

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Content-Encoding: gzip

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Vary: Accept-Encoding

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Server: Microsoft-IIS/10.0

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << set-cookie: APPSESSION=abcd;Domain=.test.com;
Path=/default/xyz

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << X-Powered-By: ASP.NET

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Date: Tue, 28 Feb 2023 03:41:23 GMT

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << *Connection: close*

2023-02-21 15:37:59,647 DEBUG [org.apache.hc.client5.http.headers]
c-0000000002 << Content-Length: 2170

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003: consume response HTTP/1.1 200 OK, entity len 2170

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003: consume response data, len 2170 bytes

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003: end of response data

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient]
c-0000000002 Connection is not kept alive

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec]
ex-0000000003: execution failed: Connection is closed

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient]
ex-0000000003 request failed: Connection is closed

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager]
ep-0000000003 close IMMEDIATE

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.nio.DefaultManagedAsyncClientConnection]
c-0000000002 Shutdown connection IMMEDIATE

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient]
ep-0000000003 endpoint closed

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.async.InternalHttpAsyncClient]
ep-0000000003 discarding endpoint

2023-02-21 15:37:59,647 DEBUG
[org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager]
ep-0000000003 releasing endpoint


-- 
Thanks & Regards,
Sreenivas

Reply via email to