-1

I am using LWP::UserAgent to check the response from a server. I get a response from port 443 but I am not able to get any response from port 8443.

When I use cURL for Windows I get a response code from both ports.

Please help me.

Borodin
  • 126,100
  • 9
  • 70
  • 144

1 Answers1

0

This example program (adapted from perldoc lwpcook) shows how to connect with a different port

It also allows turning off of the SSL verify, in case you have a home brew cert that is causing a problem

#!/usr/bin/perl
$port = $ARGV[1] || 443;
$host = $ARGV[0] || 'pause.perl.org';
$verify =$ARGV[2] || 0;
use LWP::UserAgent;
$ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => $verify});;

#$ua->agent("$0/0.1 " . $ua->agent);
$ua->agent("Mozilla/8.0");    # pretend we are very capable browser

$req = HTTP::Request->new( GET => "https://$host:$port" );
$req->header( 'Accept' => 'text/html' );

# send request
$res = $ua->request($req);

# check the outcome
if ( $res->is_success ) {
    print $res->decoded_content;
}
else {
    print "Error: " . $res->status_line . "\n";
}
Vorsprung
  • 32,923
  • 5
  • 39
  • 63
  • This is wrong since both HTTPS and port 443 are the same – Vhortex Dec 14 '22 at 04:40
  • The program in the answer takes an optional arg of the port number to use and this defaults to 443. The point however of the program is to allow HTTPS traffic on a port that is not 443. The question suggested 8443 – Vorsprung Dec 15 '22 at 07:38