<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-IN" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Thanks both for quick response.<br>
Daniel, how did you get connection upgrade. Are you setting any header for upgrade? Our sample code almost resembles your code. The difference is, you have used
</span><span style="font-size:11.0pt">httpClient.sendAsync vs httpClient.send.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><br>
</span><span style="font-size:11.0pt">POST /WarmupHandler HTTP/1.1<br>
<b>Connection: Upgrade, HTTP2-Settings<o:p></o:p></b></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt"><o:p> </o:p></span></b></p>
<p style="margin:0cm;background:white"><span style="color:black;mso-fareast-language:EN-US"><br>
</span><b><span style="color:#7F0055">var</span></b><span style="color:black"> </span>
<span style="color:#6A3E3E">httpClient</span><span style="color:black"> = HttpClient.<i>newBuilder</i>()<o:p></o:p></span></p>
<p style="margin:0cm;background:white"><span style="color:black"> .version(HttpClient.Version.</span><b><i><span style="color:#0000C0">HTTP_2</span></i></b><span style="color:black">)<o:p></o:p></span></p>
<p style="margin:0cm;background:white"><span style="color:black"> .build();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p style="margin:0cm;background:white"><b><span style="color:#7F0055">var</span></b><span style="color:black">
</span><span style="color:#6A3E3E">httpRequest</span><span style="color:black"> = HttpRequest.<i>newBuilder</i>(URI.<i>create</i>(</span><span style="color:#2A00FF"><a href="http://localhost:xxxx/pmdinhxxx/pmdinhInputxxx">http://localhost:xxxx/pmxxx/pmdxxx</a></span><span style="color:black">))<o:p></o:p></span></p>
<p style="margin:0cm;background:white"><span style="color:black"> .version(HttpClient.Version.</span><b><i><span style="color:#0000C0">HTTP_2</span></i></b><span style="color:black">)<o:p></o:p></span></p>
<p style="margin:0cm;background:white"><span style="color:black"> .POST(HttpRequest.BodyPublishers.<i>ofString</i>(</span><span style="color:#2A00FF">"_FIRST_POST_PMDINH_"</span><span style="color:black">))<o:p></o:p></span></p>
<p style="margin:0cm;background:white"><span style="color:black"> .build();<o:p></o:p></span></p>
<p style="margin:0cm;background:#E8F2FE"><b><span style="color:#7F0055">var</span></b><span style="color:black">
</span><span style="color:#6A3E3E">httpResponse</span><span style="color:black"> =
</span><span style="color:#6A3E3E">httpClient</span><span style="color:black">.send(</span><span style="color:#6A3E3E">httpRequest</span><span style="color:black">, HttpResponse.BodyHandlers.<i>ofString</i>());<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;mso-fareast-language:EN-US">Regards<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Rajesh<o:p></o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Daniel Jeliński <djelinski1@gmail.com><br>
<b>Date: </b>Friday, 15 September 2023 at 7:47 PM<br>
<b>To: </b>Asha Sunagar <Asha.Sunagar@ibm.com><br>
<b>Cc: </b>net-dev@openjdk.org <net-dev@openjdk.org>, Syed Moinudeen1 <smoinud1@in.ibm.com>, Rajesh Gudikoti <ragudiko@in.ibm.com>, Suman Mitra <summitra@in.ibm.com>, Shruthi Shruthi1 <Shruthi.Shruthi1@ibm.com><br>
<b>Subject: </b>[EXTERNAL] Re: OpenJDK (JDK 11) behavior discussion for HttpClient<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I verified the httpclient behavior using a slightly modified<br>
TrailingHeadersTest<br>
(https://github.com/openjdk/jdk/blob/master/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java
);<br>
modified the performWarmupRequest method to perform a POST instead of<br>
a GET like this:<br>
<br>
private void performWarmupRequest(HttpClient httpClient) {<br>
HttpRequest warmupReq = HttpRequest.newBuilder(warmupURI).version(HTTP_2)<br>
.POST(HttpRequest.BodyPublishers.ofString("Bwah!"))<br>
.build();<br>
httpClient.sendAsync(warmupReq, BodyHandlers.discarding()).join();<br>
}<br>
<br>
Then captured the generated traffic using Wireshark. The client sent<br>
the following sequence:<br>
<br>
POST /WarmupHandler HTTP/1.1<br>
Connection: Upgrade, HTTP2-Settings<br>
Content-Length: 5<br>
Host: 127.0.0.1:60259<br>
HTTP2-Settings: AAEAAEAAAAIAAAABAAMAAABkAAQBAAAAAAUAAEAA<br>
Upgrade: h2c<br>
User-Agent: Java-http-client/22-internal<br>
<br>
Bwah!PRI * HTTP/2.0<br>
<br>
SM<br>
<br>
<followed by binary content><br>
<br>
This appears to be the correct behavior, according to the RFC:<br>
<a href="https://datatracker.ietf.org/doc/html/rfc7540#section-3.2">https://datatracker.ietf.org/doc/html/rfc7540#section-3.2</a>
<br>
<br>
> Requests that contain a payload body MUST be sent in their entirety before the client can send HTTP/2 frames. This means that a large request can block the use of the connection until it is completely sent.<br>
<br>
Based on the above I'd say that the client behavior is correct here.<br>
Does the above match your observations?<br>
Regards,<br>
Daniel<br>
<br>
pt., 15 wrz 2023 o 14:44 Daniel Jeliński <djelinski1@gmail.com> napisał(a):<br>
><br>
> Hi Asha,<br>
> It sounds like you are not using ALPN, but instead start with a HTTP1<br>
> connection and upgrade to HTTP2.<br>
><br>
> The incorrect preface string translates to:<br>
> _FIRST_POST_PMDINH_PRI *<br>
><br>
> Is it correct to assume that "_FIRST_POST_PMDINH_" is the final bytes<br>
> of the first POST request? If that's correct, then either the client<br>
> or the server handles the content-length header incorrectly.<br>
><br>
> Can you provide a minimal reproducer?<br>
> Regards,<br>
> Daniel<br>
><br>
> pt., 15 wrz 2023 o 14:07 Asha Sunagar <Asha.Sunagar@ibm.com> napisał(a):<br>
> ><br>
> > Hello Team,<br>
> ><br>
> ><br>
> > We are facing invalid preface issue when we send POST request using HttpClient. We overcame this issue using workaround mentioned in openjdk issue. The workaround was to use a blank request before making post request.<br>
> ><br>
> ><br>
> ><br>
> > Based on our below observations, the Preface String is different in Failure & Success case,<br>
> ><br>
> ><br>
> > The Preface String for<br>
> > 1.1) Post Request without blank request --> we get GOAWAY Exception (Failure case)<br>
> ><br>
> > Preface String: [80, 82, 73, 32, 42, 32, 72, 84, 84, 80, 47, 50, 46, 48, 13, 10, 13, 10, 83, 77, 13, 10, 13, 10]<br>
> ><br>
> > Preface String: [95, 70, 73, 82, 83, 84, 95, 80, 79, 83, 84, 95, 80, 77, 68, 73, 78, 72, 95, 80, 82, 73, 32, 42]<br>
> ><br>
> > Preface String: [95, 70, 73, 82, 83, 84, 95, 80, 79, 83, 84, 95, 80, 77, 68, 73, 78, 72, 95, 80, 82, 73, 32, 42]<br>
> ><br>
> ><br>
> ><br>
> > 1.2) Workaround case with a blank request (Success Case)<br>
> ><br>
> > Preface String: [80, 82, 73, 32, 42, 32, 72, 84, 84, 80, 47, 50, 46, 48, 13, 10, 13, 10, 83, 77, 13, 10, 13, 10]<br>
> ><br>
> > Preface String: [80, 82, 73, 32, 42, 32, 72, 84, 84, 80, 47, 50, 46, 48, 13, 10, 13, 10, 83, 77, 13, 10, 13, 10]<br>
> ><br>
> > Preface String: [80, 82, 73, 32, 42, 32, 72, 84, 84, 80, 47, 50, 46, 48, 13, 10, 13, 10, 83, 77, 13, 10, 13, 10]<br>
> ><br>
> ><br>
> ><br>
> > 2) LOGS<br>
> > 2.1) Post Request without blank request :We get the error "an error occurred processing a frame": Failed to complete the connection preface from Liberty server and GOAWAY Exception.<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 com.ibm.ws.http.channel.h2internal.FrameReadProcessor 3 checkConnectionPreface: processNextFrame-: stream: 0 frame type: Magic Preface direction: READ_IN H2InboundLink hc: 101118290<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 com.ibm.ws.http.channel.h2internal.FrameReadProcessor 3 checkConnectionPreface: Preface String: [95, 70, 73, 82, 83, 84, 95, 80, 79, 83, 84, 95, 80, 77, 68, 73, 78, 72, 95, 80, 82, 73, 32, 42]<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 SystemOut O PMDINH, FrameReadProcessor CHECKPOINT 2, throw new ProtocolException --- Connection preface/magic was invalid<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 SystemOut O PMDINH, FrameReadProcessor CHECKPOINT 3, throw new ProtocolException --- Cconnection preface<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 com.ibm.ws.http.channel.h2internal.H2InboundLink 3 processRead: an error occurred processing a frame: Failed to complete the connection preface<br>
> ><br>
> > [9/7/23, 15:41:10:595 IST] 00000058 id=00000000 com.ibm.ws.http.channel.h2internal.H2InboundLink 3 close(vc,e): :linkstatus: is: INIT :close: H2InboundLink hc: 101118290exception: com.ibm.ws.http.channel.h2internal.exceptions.ProtocolException:
Failed to complete the connection preface<br>
> ><br>
> ><br>
> ><br>
> > 2.2) Workaround case with a blank request<br>
> ><br>
> > [9/7/23, 15:54:21:528 IST] 0000005a id=00000000 com.ibm.ws.http.channel.h2internal.FrameReadProcessor 3 checkConnectionPreface: processNextFrame-: stream: 0 frame type: Magic Preface direction: READ_IN H2InboundLink hc: 551136004<br>
> ><br>
> > [9/7/23, 15:54:21:528 IST] 0000005a id=00000000 com.ibm.ws.http.channel.h2internal.FrameReadProcessor 3 checkConnectionPreface: Preface String: [80, 82, 73, 32, 42, 32, 72, 84, 84, 80, 47, 50, 46, 48, 13, 10, 13, 10, 83, 77, 13, 10, 13, 10]<br>
> ><br>
> > [9/7/23, 15:54:21:528 IST] 0000005a id=00000000 com.ibm.ws.http.channel.h2internal.H2InboundLink 3 createNewInboundLink entry: stream-id: 0<br>
> ><br>
> > [9/7/23, 15:54:21:528 IST] 0000005a id=00000000 com.ibm.ws.http.channel.internal.inbound.HttpInboundLink<br>
> ><br>
> ><br>
> ><br>
> > Please let us to know whether it is an expected behavior or an issue? Or is there a way to handle such scenarios?<br>
> ><br>
> ><br>
> ><br>
> > Thanks & Regards,<br>
> ><br>
> > Asha H Sunagar<br>
> ><br>
> > IGA - JTC | Global Business Services – IBM<br>
> ><br>
> > Phone: +91 8884256034<br>
> ><br>
> > Email : asha.sunagar@ibm.com<br>
> ><br>
> ><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>