400 Bad Request response while retrieving recorded requests (java.util.concurrent.TimeoutException)
See original GitHub issueDescribe the issue When trying to retrieve recorded requests (https://www.mock-server.com/mock_server/debugging_issues.html#retrieving_recorded_requests), mock-server hangs for a moment and returns 400 Bad Request response. Internally Mock Server fails to handle the request with java.util.concurrent.TimeoutException.
What you are trying to do I am trying to retrieve recorded request to introspect the request sent by the service being tested.
MockServer version 5.11.2 (Docker image with latest label)
To Reproduce Steps to reproduce the issue:
- MockServer run with Docker image
- Expectation:
PUT /mockserver/expectation
{"httpRequest": {"path": "/emails/messages/"},
"httpResponse": {"body": {"/1234/": "boo"}}
}
- What error you saw
PUT /mockserver/retrieve?type=REQUESTS
{"path": "/emails/messages/"}
response:
HTTP 400
Exception retrieving state for {\n "method" : "PUT",\n "path" : "/mockserver/retrieve",\n "queryStringParameters" : {\n "type" : [ "REQUESTS" ]\n },\n "headers" : {\n "Host" : [ "myservice-mock:1080" ],\n "User-Agent" : [ "python-requests/2.25.1" ],\n "Accept-Encoding" : [ "gzip, deflate" ],\n "Accept" : [ "*/*" ],\n "Connection" : [ "keep-alive" ],\n "Content-Length" : [ "29" ],\n "Content-Type" : [ "application/json" ]\n },\n "keepAlive" : true,\n "secure" : false,\n "body" : {\n "contentType" : "application/json",\n "type" : "JSON",\n "json" : {\n "path" : "/emails/messages/"\n }\n }\n}
Expected behaviour 3. Receive recorded requests
{"path": "/emails/messages/"}
response:
HTTP 200
[…]
MockServer Log DEBUG level:
2021-11-10 12:35:27 5.11.2 SEVERE 1080 exception handling request:
{
"method" : "PUT",
"path" : "/mockserver/retrieve",
"queryStringParameters" : {
"type" : [ "REQUESTS" ]
},
"headers" : {
"Host" : [ "panoptic-mock:1080" ],
"User-Agent" : [ "python-requests/2.25.1" ],
"Accept-Encoding" : [ "gzip, deflate" ],
"Accept" : [ "*/*" ],
"Connection" : [ "keep-alive" ],
"Content-Length" : [ "47" ],
"Content-Type" : [ "application/json" ]
},
"keepAlive" : true,
"secure" : false,
"body" : {
"path" : "/emails/messages/",
"method" : "POST"
}
}
error:
java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
at org.mockserver.mock.HttpState.retrieve(HttpState.java:475)
at org.mockserver.mock.HttpState.handle(HttpState.java:607)
at org.mockserver.netty.HttpRequestHandler.channelRead0(HttpRequestHandler.java:92)
at org.mockserver.netty.HttpRequestHandler.channelRead0(HttpRequestHandler.java:48)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.dashboard.DashboardWebSocketHandler.channelRead(DashboardWebSocketHandler.java:140)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.closurecallback.websocketregistry.CallbackWebSocketServerHandler.channelRead(CallbackWebSocketServerHandler.java:55)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.netty.unification.PortUnificationHandler.switchToHttp(PortUnificationHandler.java:260)
at org.mockserver.netty.unification.PortUnificationHandler.decode(PortUnificationHandler.java:138)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501)
at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:834)
2021-11-10 12:35:27 5.11.2 SEVERE 1080 exception processing {
"method" : "PUT",
"path" : "/mockserver/retrieve",
"queryStringParameters" : {
"type" : [ "REQUESTS" ]
},
"headers" : {
"Host" : [ "panoptic-mock:1080" ],
"User-Agent" : [ "python-requests/2.25.1" ],
"Accept-Encoding" : [ "gzip, deflate" ],
"Accept" : [ "*/*" ],
"Connection" : [ "keep-alive" ],
"Content-Length" : [ "47" ],
"Content-Type" : [ "application/json" ]
},
"keepAlive" : true,
"secure" : false,
"body" : {
"contentType" : "application/json",
"type" : "JSON",
"json" : {
"path" : "/emails/messages/",
"method" : "POST"
}
}
}
java.lang.RuntimeException: Exception retrieving state for {
"method" : "PUT",
"path" : "/mockserver/retrieve",
"queryStringParameters" : {
"type" : [ "REQUESTS" ]
},
"headers" : {
"Host" : [ "panoptic-mock:1080" ],
"User-Agent" : [ "python-requests/2.25.1" ],
"Accept-Encoding" : [ "gzip, deflate" ],
"Accept" : [ "*/*" ],
"Connection" : [ "keep-alive" ],
"Content-Length" : [ "47" ],
"Content-Type" : [ "application/json" ]
},
"keepAlive" : true,
"secure" : false,
"body" : {
"contentType" : "application/json",
"type" : "JSON",
"json" : {
"path" : "/emails/messages/",
"method" : "POST"
}
}
}
at org.mockserver.mock.HttpState.retrieve(HttpState.java:485)
at org.mockserver.mock.HttpState.handle(HttpState.java:607)
at org.mockserver.netty.HttpRequestHandler.channelRead0(HttpRequestHandler.java:92)
at org.mockserver.netty.HttpRequestHandler.channelRead0(HttpRequestHandler.java:48)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.dashboard.DashboardWebSocketHandler.channelRead(DashboardWebSocketHandler.java:140)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.closurecallback.websocketregistry.CallbackWebSocketServerHandler.channelRead(CallbackWebSocketServerHandler.java:55)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.mockserver.netty.unification.PortUnificationHandler.switchToHttp(PortUnificationHandler.java:260)
at org.mockserver.netty.unification.PortUnificationHandler.decode(PortUnificationHandler.java:138)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501)
at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
at org.mockserver.mock.HttpState.retrieve(HttpState.java:475)
... 56 more
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:12
Top Results From Across the Web
java.util.concurrent.TimeoutException Error - Stack Overflow
1 Answer 1 ... Based on the stack trace you've shared, the TimeoutException has been thrown from the invocation of the blocking method...
Read more >400 Bad Request“ return when POST Rest API call to ... - AskF5
To work around this issue, you can restart the restjavad service. Login to tmsh. Run below command to restart restjavad: restart sys service ......
Read more >Error handling with DynamoDB - AWS Documentation
An HTTP 400 status code indicates a problem with your request, such as authentication failure, missing required parameters, or exceeding a table's provisioned ......
Read more >Solved: 400: Bad Request : The request could not be comple...
A 400 means that the request was malformed. In other words, the data stream sent by the client to ...
Read more >3. Resolved and Known Issues Red Hat JBoss Enterprise ...
If the remote naming context object was closed when done, the client logged the error shown below, because the ejb-client context was already...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, I pulled 5.13.1 this time. And it seems to fix the issue 🎉 . I have 100% success rate so far (4 runs).
Thank you very much for your work and help on it!
It looks like the snapshot docker tag doesn’t contain the latest snapshot it is using
5.11.3-SNAPSHOT
(as shown in your logs) but it should be5.13.1-SNAPSHOT
.I’ve tracked down the cause and it turns out sonatype (behind maven central) has an open bug for not updating the LATEST tag for snapshots, as shown in the metadata xml downloaded from maven central snapshot repo:
I’ve committed a hack fix for this to explicitly specify the latest snapshot version.
Can you please pull the latest snapshot tag again and retry:
When you run you should see each log event starts has
5.13.1-SNAPSHOT
, for example: