mcdcorp / opentest

Open source test automation tool for web applications, mobile apps and APIs
https://getopentest.org
MIT License
447 stars 107 forks source link

"java.net.SocketException: Connection reset" upon performing org.getopentest.actions.HttpRequest #512

Closed jdaigle-softvision closed 2 years ago

jdaigle-softvision commented 2 years ago

OpenTest version number: 1.2.4

Performing an org.getopentest.actions.HttpRequest to certain URLs causes a java.net.SocketException: Connection reset, after which test execution hangs.

Steps to reproduce:

  1. Perform an org.getopentest.actions.HttpRequest to an affected URL. Example: $runAction("org.getopentest.actions.HttpRequest", { url: $data("urls").baseUrl + $data("urls").products + "?categoryId=" + categories[i].categories[j].categories[k].id });
  2. Note that the request succeeds, but a java.net.SocketException: Connection reset error is displayed, and test execution hangs.

Relevant log information:

TRACE: Initializing action org.getopentest.actions.HttpRequest...
Executing action org.getopentest.actions.HttpRequest with arguments {"url":"[redacted]/v1/products?categoryId=[redacted]"}...
DEBUG: The server returned HTTP status code 200.
DEBUG: The output values from action org.getopentest.actions.HttpRequest were: 
    >>>>> headers = {"X-Cache":"Hit from cloudfront","X-Amz-Cf-Pop":"DFW55-C3","Connection":"keep-alive","Date":"Mon, 13 Sep 2021 13:20:36 GMT","Via":"1.1 86e7490fde5a22b9c665579fff4df533.cloudfront.net (CloudFront)","x-trace-id":"9ed4affa-0ccb-4b2a-a07c-5f0d048878d7","Cache-Control":"max-age=3600","ETag":"61782870-1495-11ec-8c4c-631edc7b3bd9","X-Amz-Cf-Id":"FWKuFpbJOCX5bF-5WM5u-UGN50lqluJkXhVnE1kSHxh_YwvBzueXhg==","Content-Length":"116","Age":"775","Content-Type":"application/json; charset=utf-8","X-Powered-By":"Express"}
    >>>>> body = {"appliedFilters":[],"hasNextPage":false,"totalProducts":0,"filters":[],"sorts":[],"visualFilters":[],"products":[]}
    >>>>> durationMs = 93
    >>>>> statusCode = 200
ERROR: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:210)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at org.getopentest.http.HttpRequest.execute(HttpRequest.java:126)
    at org.getopentest.base.TestActor.executeTestSegment(TestActor.java:2163)
    at org.getopentest.base.TestActor.runOneSession(TestActor.java:2981)
    at org.getopentest.base.TestActor.runOneSession(TestActor.java:3017)
    at org.getopentest.Main.main(Main.java:20)
adrianth commented 2 years ago

This could be related to a bug that we discovered some time ago, where OpenTest doest clean up properly after making HTTP requests. This bug was solved in versions 1.3.X, but these versions are not published as "latest" just yet. This is not an issue normally, but in your case I'm thinking it may be triggering CloudFront's DDoS protection or some rate limiting logic they might have in there.

Version 1.3.2 should go live pretty soon, but if you want to try it out in the meantime, you can install it like this:

npm install opentest@beta -g

If you see any problems please report them as a new issue. If you need to revert to the current stable version you can always do that with:

npm install opentest -g
jdaigle-softvision commented 2 years ago

Thanks @adrianth. I installed version 1.3.2 and ran the same test case. I seem to have the same issue:

`iterating j=2 for categories.length 3 with name Doorbusters TRACE: Initializing action org.getopentest.actions.HttpRequest... Executing action org.getopentest.actions.HttpRequest with arguments {"url":"https://[redacted]/v1/products?categoryId=[redacted]"}... DEBUG: The server returned HTTP status code 200. DEBUG: The output values from action org.getopentest.actions.HttpRequest were:

headers = {"X-Cache":"Hit from cloudfront","X-Amz-Cf-Pop":"DFW55-C3","Connection":"keep-alive","Date":"Tue, 14 Sep 2021 12:48:18 GMT","Via":"1.1 b55625a3b6969f4acb104fcc2667d17a.cloudfront.net (CloudFront)","x-trace-id":"892e99a6-e627-46c9-a01d-8a671e13aca4","Cache-Control":"max-age=3600","ETag":"0937bb10-155a-11ec-9d17-15255c4c04f8","X-Amz-Cf-Id":"V81AN_2IeOmi7FQP7RXSXHaijkkNW2B5BrtpulNMkksV9etgsAoEGg==","Content-Length":"116","Age":"1891","Content-Type":"application/json; charset=utf-8","X-Powered-By":"Express"} body = {"appliedFilters":[],"hasNextPage":false,"totalProducts":0,"filters":[],"sorts":[],"visualFilters":[],"products":[]} durationMs = 114 statusCode = 200 ERROR: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at org.getopentest.http.HttpRequest.execute(HttpRequest.java:154) at org.getopentest.base.TestActor.executeTestSegment(TestActor.java:2205) at org.getopentest.base.TestActor.runOneSession(TestActor.java:3077) at org.getopentest.base.TestActor.runOneSession(TestActor.java:3113) at org.getopentest.Main.main(Main.java:20)`

It's interesting to hear that it might be caused by CloudFront's DDoS protection - this is indeed after a few hundred requests, but it's the last possible request in the loop, and I see a 200 response with the data from the request?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.