title: Perl LWP::UserAgent, https proxy to specific https web site, unknown protocol error
body: <p>Read all I could find about subject... can't figure how make it work. </p>
  
  <p>I use freshly updated (09 Jan 2015)  Active State Perl, and a standard approach </p>
  
  <pre><code>my $ua=LWP::UserAgent-&gt;new();  
  $ua-&gt;agent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/33.0');
  $ua-&gt;timeout(120);
  $ua-&gt;cookie_jar( {} );
  $ua-&gt;proxy(['https'],'https://199.200.120.140:8089') #taken from http://proxylist.hidemyass.com/search-1308872#listable
  my $response = $ua-&gt;get('https://www.comparis.ch');   #this web site I struggle with, I can connect to https://github.com for example... But I also can connect to comparis.ch through same proxy using urllib3 on Python3.4... 
  </code></pre>
  
  <p>If somebody can explain how to get 200 from the web site? 
  The output from </p>
  
  <p>The response returns either Timeout (if I use http proxy, or </p>
  
  <pre><code>LWP::Protocol::https::Socket: SSL connect attempt failed error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol at E:/Perl64/lib/LWP/Protocol/http.pm line 49." 
  </code></pre>
  
  <p>If I try   </p>
  
  <pre><code>LWP::UserAgent-&gt;new(ssl_opts =&gt; { verify_hostname =&gt; 0, SSL_version =&gt; 'SSLv3' });
  </code></pre>
  
  <p>Then I getting </p>
  
  <pre><code>LWP::Protocol::https::Socket: SSL connect attempt failed error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number at E:/Perl64/lib/LWP/Protocol/http.pm line 49.
  </code></pre>
  
  <p>I think that web site timeouting connections from some regions, so have to use proxy from the USA or Western Europe. </p>
  
  <p>As requested I added output for debug (for simple UserAgent->new() -- no options), it tries two proxies 192.3.121.204:3128 and 64.31.22.131:7808 from <a href="http://proxylist.hidemyass.com/search-1305502#listable" rel="nofollow">http://proxylist.hidemyass.com/search-1305502#listable</a>. The 1st seems like just timed out (most likely was blocked) but second shows different behavior.</p>
  
  <pre><code>perl -MIO::Socket::SSL=debug4 test.pl
  
  DEBUG: .../IO/Socket/SSL.pm:2555: new ctx 61267216
  DEBUG: .../IO/Socket/SSL.pm:539: socket not yet connected
  DEBUG: .../IO/Socket/SSL.pm:1769: IO::Socket::INET configuration failed
  DEBUG: .../IO/Socket/SSL.pm:2588: free ctx 61267216 open=61267216
  DEBUG: .../IO/Socket/SSL.pm:2593: free ctx 61267216 callback
  DEBUG: .../IO/Socket/SSL.pm:2600: OK free ctx 61267216
  500 Can't connect to 192.3.121.204:3128 (10060)
  Content-Type: text/plain
  Client-Date: Fri, 09 Jan 2015 10:15:18 GMT
  Client-Warning: Internal response
  
  Can't connect to 192.3.121.204:3128 (10060)
  
  LWP::Protocol::https::Socket: connect: 10060 at E:/Perl64/lib/LWP/Protocol/http.pm line 49.
  
  DEBUG: .../IO/Socket/SSL.pm:2555: new ctx 61267216
  DEBUG: .../IO/Socket/SSL.pm:539: socket not yet connected
  DEBUG: .../IO/Socket/SSL.pm:541: socket connected
  DEBUG: .../IO/Socket/SSL.pm:563: ssl handshake not started
  DEBUG: .../IO/Socket/SSL.pm:599: not using SNI because hostname is unknown
  DEBUG: .../IO/Socket/SSL.pm:650: set socket to non-blocking to enforce timeout=120
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:1780: SSL connect attempt failed
  
  DEBUG: .../IO/Socket/SSL.pm:1785: SSL connect attempt failed error:140770FC:SSL     routines:SSL23_GET_SERVER_HELLO:unknown protocol
  DEBUG: .../IO/Socket/SSL.pm:669: fatal SSL error: SSL connect attempt failed error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
  DEBUG: .../IO/Socket/SSL.pm:1769: IO::Socket::INET configuration failed
  DEBUG: .../IO/Socket/SSL.pm:2588: free ctx 61267216 open=61267216
  DEBUG: .../IO/Socket/SSL.pm:2593: free ctx 61267216 callback
  DEBUG: .../IO/Socket/SSL.pm:2600: OK free ctx 61267216
  500 Can't connect to 64.31.22.131:7808
  Content-Type: text/plain
  Client-Date: Fri, 09 Jan 2015 10:15:19 GMT
  Client-Warning: Internal response
  
  Can't connect to 64.31.22.131:7808
  
  LWP::Protocol::https::Socket: SSL connect attempt failed error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol at E:/Perl64/lib/LWP/Protocol/http.pm line 49.
  </code></pre>
  
  <p>After Stefan suggestion I used http:// for proxy address (and not https) and this produced a little bit better results as follows, also, it perfectly works under Ubuntu, but not in windows... </p>
  
  <pre><code>DEBUG: .../IO/Socket/SSL.pm:2555: new ctx 65664688
  DEBUG: .../IO/Socket/SSL.pm:1354: start handshake
  DEBUG: .../IO/Socket/SSL.pm:563: ssl handshake not started
  DEBUG: .../IO/Socket/SSL.pm:599: not using SNI because hostname is unknown
  DEBUG: .../IO/Socket/SSL.pm:650: set socket to non-blocking to enforce timeout=120
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:2411: ok=1 cert=69181312
  DEBUG: .../IO/Socket/SSL.pm:2411: ok=1 cert=69943488
  DEBUG: .../IO/Socket/SSL.pm:2411: ok=1 cert=69943136
  DEBUG: .../IO/Socket/SSL.pm:1559: scheme=www cert=69943136
  DEBUG: .../IO/Socket/SSL.pm:1569: identity=www.comparis.ch cn=www.comparis.ch alt=2 www.comparis.ch 2 it.comparis.ch 2 en.comparis.ch 2 fr.comparis.ch
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; -1
  DEBUG: .../IO/Socket/SSL.pm:673: ssl handshake in progress
  DEBUG: .../IO/Socket/SSL.pm:683: waiting for fd to become ready: SSL wants a read first
  DEBUG: .../IO/Socket/SSL.pm:703: socket ready, retrying connect
  DEBUG: .../IO/Socket/SSL.pm:663: Net::SSLeay::connect -&gt; 1
  DEBUG: .../IO/Socket/SSL.pm:718: ssl handshake done
  DEBUG: .../IO/Socket/SSL.pm:2588: free ctx 65664688 open=65664688
  DEBUG: .../IO/Socket/SSL.pm:2593: free ctx 65664688 callback
  DEBUG: .../IO/Socket/SSL.pm:2600: OK free ctx 65664688
  500 Status read failed:A non-blocking socket operation could not be completed
  immediately
  Content-Type: text/plain
  Client-Date: Fri, 09 Jan 2015 16:49:31 GMT
  Client-Warning: Internal response
  
  Status read failed: A non-blocking socket operation could not be completed immediately
  at E:/Perl64/lib/Net/HTTP/Methods.pm line 276.
  </code></pre>
  
  <p>I guess it's now a little bit different matter, but I searched web, and could not find any answers for this. </p>