<div dir="ltr">Hi,<div><br></div><div>I am trying to use UndertowClient to call another service in the current service handleRequest using HTTP 2.0. If I have concurrent requests to the current service, then I will get the following error. </div><div><br></div><div><div>java.io.IOException: UT001033: Invalid connection state</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>at io.undertow.client.http.HttpClientConnection.sendRequest(HttpClientConnection.java:336)</div></div><div><br></div><div>Since HTTP 2.0 connection is multiplex, so I use instance variables for UndertowClient instance and ClientConnection instance and don&#39;t close the connection for each call. </div><div><br></div><div>My question is how many requests can go through the same connection? Is the Invalid connection state caused by too many requests in the same connection? If yes, I can use a connection pool just like the HTTP 1.1. Also, is it possible that the server will close the connection if it is idle for a period of time? </div><div><br></div><div>Here is the handler code for reference.</div><div><br></div><div><div>public class DataGetHandler implements HttpHandler {</div><div>    UndertowClient client = UndertowClient.getInstance();</div><div>    ClientConnection connection;</div><div><br></div><div>    @Override</div><div>    public void handleRequest(HttpServerExchange exchange) throws Exception {</div><div>        List&lt;String&gt; list = new ArrayList&lt;&gt;();</div><div>        final CountDownLatch latch = new CountDownLatch(1);</div><div>        if(connection == null) {</div><div>            try {</div><div>                connection = client.connect(new URI(apidHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();</div><div>            } catch (Exception e) {</div><div>                logger.error(&quot;Exeption:&quot;, e);</div><div>                throw new ClientException(e);</div><div>            }</div><div>        }</div><div>        final AtomicReference&lt;ClientResponse&gt; reference = new AtomicReference&lt;&gt;();</div><div>        try {</div><div>            ClientRequest request = new ClientRequest().setMethod(Methods.GET).setPath(apidPath);</div><div>            connection.sendRequest(request, client.createClientCallback(reference, latch));</div><div>            latch.await();</div><div>            int statusCode = reference.get().getResponseCode();</div><div>            if(statusCode &gt;= 300){</div><div>                throw new Exception(&quot;Failed to call API D: &quot; + statusCode);</div><div>            }</div><div>            List&lt;String&gt; apidList = Config.getInstance().getMapper().readValue(reference.get().getAttachment(Http2Client.RESPONSE_BODY),</div><div>                    new TypeReference&lt;List&lt;String&gt;&gt;(){});</div><div>            list.addAll(apidList);</div><div>        } catch (Exception e) {</div><div>            logger.error(&quot;Exception:&quot;, e);</div><div>            throw new ClientException(e);</div><div>        }</div><div>        list.add(&quot;API C: Message 1&quot;);</div><div>        list.add(&quot;API C: Message 2&quot;);</div><div>        exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(list));</div><div>    }</div><div>}</div></div><div><br></div></div>