[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-net-dev
Subject:    HttpsURLConnection
From:       Somshekar C Kadam <somkadam76 () gmail ! com>
Date:       2019-08-21 13:22:15
Message-ID: CALbGK-ptBp0FB9RNeR4+pvJzm5g-52=bGo=VKhDzYecLuerXng () mail ! gmail ! com
[Download RAW message or body]

I am newbie to Java.
we have on our environment
Linux kernel 4.9, java 1.8 version using tls 1.2 default


   1. using curl when we give any https link , it returns within 2 seconds
   2. using java program using httpurlconnection class we get 10 seconds or
   more delay.
   3. Even removed some ciphers thought it may take sometime but that is
   not the case.
   4. Trying an alternative to httpurlconnection class apache httpclient,
   having issues compiling and running it, any pointers will help.
   5. Also any pointers or suggestion why we have 10 seconds delay on https
   connection ?
   6. I have tested using oracle java 8 also, same result, also tried
   zulu11 version of java same delay.
   7. Any suggestions would help here thanks in advance
   8. This is being tested on Armv7 board, we see the delay.
   But when I run this in intel machine its just takes max 1 to 2 seconds
   using sam java program.
   So stuck on this.
   9. I am seeing  on ARM lot many seconds wasted on this as shown below
   logs. Where as in Intel I did not see a single reference, seems that is
   something to do with it, need to  look further into it.

   ============
   15033 08:10:27.254816 clock_gettime(CLOCK_MONOTONIC, {4286, 606936331})
   = 0
   15033 08:10:27.255070 clock_gettime(CLOCK_MONOTONIC, {4286, 607189947})
   = 0
   15033 08:10:27.255504 clock_gettime(CLOCK_MONOTONIC, {4286, 607662716})
   = 0
   15033 08:10:27.255924 clock_gettime(CLOCK_MONOTONIC, {4286, 608074100})
   = 0
   ==================================
   10. Even if I try this simple httpsurlconnection java program to print
   content it takes more than 10 seconds on ARM not in intel. Not sure why
   please help

   HttpsClient.java
   ========================
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.security.cert.Certificate;
   import java.io.*;

   import javax.net.ssl.HttpsURLConnection;
   import javax.net.ssl.SSLPeerUnverifiedException;

   public class HttpsClient {

      public static void main(String[] args)
      {
           new HttpsClient().testIt();
      }

      private void testIt(){

         //String https_url = "https://www.google.com/";
         String https_url = "
   https://transparencyreport.google.com/https/overview?hl=en";
         URL url;
         try {

       url = new URL(https_url);
       HttpsURLConnection con = (HttpsURLConnection)url.openConnection();

       //dumpl all cert info
       print_https_cert(con);

       //dump all the content
       print_content(con);

         } catch (MalformedURLException e) {
       e.printStackTrace();
         } catch (IOException e) {
       e.printStackTrace();
         }

      }

      private void print_https_cert(HttpsURLConnection con){

       if(con!=null){

         try {

   System.out.println("Response Code : " + con.getResponseCode());
   System.out.println("Cipher Suite : " + con.getCipherSuite());
   System.out.println("\n");

   Certificate[] certs = con.getServerCertificates();
   for(Certificate cert : certs){
     System.out.println("Cert Type : " + cert.getType());
     System.out.println("Cert Hash Code : " + cert.hashCode());
     System.out.println("Cert Public Key Algorithm : "
                                       +
   cert.getPublicKey().getAlgorithm());
     System.out.println("Cert Public Key Format : "
                                       + cert.getPublicKey().getFormat());
     System.out.println("\n");
   }

   } catch (SSLPeerUnverifiedException e) {
   e.printStackTrace();
   } catch (IOException e){
   e.printStackTrace();
   }

        }

      }

      private void print_content(HttpsURLConnection con){
   if(con!=null){

   try {

     System.out.println("****** Content of the URL ********");
     BufferedReader br =
   new BufferedReader(
   new InputStreamReader(con.getInputStream()));

     String input;

     while ((input = br.readLine()) != null){
        System.out.println(input);
     }
     br.close();

   } catch (IOException e) {
     e.printStackTrace();
   }

          }

      }

   }



   ======================


Regards
Somshekar C Kadam
9036660538

[Attachment #3 (text/html)]

<div dir="ltr"><div>I am newbie to Java.  </div><div>we have on our environment  \
</div><div>Linux kernel 4.9, java 1.8 version using tls 1.2 \
default</div><div><br></div><div><ol><li style="margin-left:15px">using curl when we \
give any https link , it returns within 2 seconds  <br></li><li \
style="margin-left:15px">using java program using httpurlconnection class we get 10 \
seconds or more delay.  <br></li><li style="margin-left:15px">Even removed some \
ciphers thought it may take sometime but that is not the case.  </li><li \
style="margin-left:15px">Trying an alternative to httpurlconnection class apache \
httpclient, having issues compiling and running it, any pointers will help.  </li><li \
style="margin-left:15px">Also any pointers or suggestion why we have 10 seconds delay \
on https connection ?</li><li style="margin-left:15px">I have tested using oracle \
java 8 also, same result, also tried zulu11 version of java same delay.</li><li \
style="margin-left:15px">Any suggestions would help here thanks in advance</li><li \
style="margin-left:15px"><div>This is being tested on Armv7 board, we see the \
delay.</div><div>But when I run this in intel machine its just takes max 1 to 2 \
seconds using sam java program.  </div><div>So stuck on this.  </div></li><li \
style="margin-left:15px"><div class="gmail-gs" style="margin:0px;padding:0px 0px \
20px;width:885px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><div \
class="gmail-"><div id="gmail-:4l7" class="gmail-ii gmail-gt gmail-adO" \
style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div \
id="gmail-:4dt" class="gmail-a3s gmail-aXjCH" \
style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font \
-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><div \
dir="ltr"><div>I am seeing   on ARM lot many seconds wasted on this as shown below \
logs. Where as in Intel I did not see a single reference, seems that is something to \
do with it, need to   look further into it.  \
</div><div><br></div><div>============</div><div>15033 08:10:27.254816 \
clock_gettime(CLOCK_MONOTONIC, {4286, 606936331}) = 0<br>15033 08:10:27.255070 \
clock_gettime(CLOCK_MONOTONIC, {4286, 607189947}) = 0<br>15033 08:10:27.255504 \
clock_gettime(CLOCK_MONOTONIC, {4286, 607662716}) = 0<br>15033 08:10:27.255924 \
clock_gettime(CLOCK_MONOTONIC, {4286, 608074100}) = 0<br><div><div dir="ltr" \
class="gmail-m_651174221239609551gmail_signature"><div \
dir="ltr">==================================</div></div></div></div></div></div></div></div></div></li><li \
style="margin-left:15px"><div><div>Even if I try this simple httpsurlconnection java \
program to print content it takes more than 10 seconds on ARM not in intel. Not sure \
why please help  </div><div><br></div><div>HttpsClient.java</div><div>========================</div><div>import \
java.net.MalformedURLException;<br>import java.net.URL;<br>import \
java.security.cert.Certificate;<br>import java.io.*;<br><br>import \
javax.net.ssl.HttpsURLConnection;<br>import \
javax.net.ssl.SSLPeerUnverifiedException;<br><br>public class HttpsClient {<br><br>   \
public static void main(String[] args)<br>     {<br>            new \
HttpsClient().testIt();<br>     }<br><br>     private void testIt(){<br><br>         \
//String https_url = &quot;<a href="https://www.google.com/" \
target="_blank">https://www.google.com/</a>&quot;;<br>         String https_url = \
&quot;<a href="https://transparencyreport.google.com/https/overview?hl=en" \
target="_blank">https://transparencyreport.google.com/https/overview?hl=en</a>&quot;;<br> \
URL url;<br>         try {<br><br>      url = new URL(https_url);<br>      \
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();<br><br>      \
//dumpl all cert info<br>      print_https_cert(con);<br><br>      //dump all the \
content<br>      print_content(con);<br><br>         } catch (MalformedURLException \
e) {<br>      e.printStackTrace();<br>         } catch (IOException e) {<br>      \
e.printStackTrace();<br>         }<br><br>     }<br><br>     private void \
print_https_cert(HttpsURLConnection con){<br>        <br>      if(con!=null){<br><br> \
try {<br><br>System.out.println(&quot;Response Code : &quot; + \
con.getResponseCode());<br>System.out.println(&quot;Cipher Suite : &quot; + \
con.getCipherSuite());<br>System.out.println(&quot;\n&quot;);<br><br>Certificate[] \
certs = con.getServerCertificates();<br>for(Certificate cert : certs){<br>   \
System.out.println(&quot;Cert Type : &quot; + cert.getType());<br>   \
System.out.println(&quot;Cert Hash Code : &quot; + cert.hashCode());<br>   \
System.out.println(&quot;Cert Public Key Algorithm : &quot;  <br>                     \
+ cert.getPublicKey().getAlgorithm());<br>   System.out.println(&quot;Cert Public Key \
Format : &quot;  <br>                                                      + \
cert.getPublicKey().getFormat());<br>   \
System.out.println(&quot;\n&quot;);<br>}<br><br>} catch (SSLPeerUnverifiedException \
e) {<br>e.printStackTrace();<br>} catch (IOException \
e){<br>e.printStackTrace();<br>}<br><br>        }<br><br>     }<br><br>     private \
void print_content(HttpsURLConnection con){<br>if(con!=null){<br><br>try {<br><br>   \
System.out.println(&quot;****** Content of the URL ********&quot;);	<br>   \
BufferedReader br =  <br>new BufferedReader(<br>new \
InputStreamReader(con.getInputStream()));<br><br>   String input;<br><br>   while \
((input = br.readLine()) != null){<br>        System.out.println(input);<br>   }<br>  \
br.close();<br><br>} catch (IOException e) {<br>   e.printStackTrace();<br>}<br><br>  \
}<br><br>     }<br><br>}<br></div><div><br></div><div><br></div><div><br>======================<div \
class="gmail-yj6qo gmail-ajU" style="outline:none;padding:10px \
0px;width:22px;margin:2px 0px 0px"><br \
class="gmail-Apple-interchange-newline"></div></div></div></li></ol></div><div><div \
dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div \
dir="ltr">Regards<div>Somshekar C \
Kadam</div><div>9036660538</div></div></div></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic