IO::Socket::Socks can print the SOCKS exchange when a connection fails. Supply the proxy, destination and debug option explicitly:

use IO::Socket::Socks;

my $socket = IO::Socket::Socks->new(
    ProxyAddr   => 'proxy.example',
    ProxyPort   => 1080,
    ConnectAddr => 'www.example.com',
    ConnectPort => 80,
    SocksVersion => 5,
    SocksDebug  => 1,
    Timeout     => 10,
) or die $SOCKS_ERROR;

$socket->close();

The module documents SocksDebug as displaying SOCKS traffic in a protocol-oriented form. Use it to see how far negotiation progresses and inspect a returned SOCKS failure code.

ProxyAddr and ProxyPort identify the intermediary. An unauthenticated address from the SOCKS5 proxy list can fill those fields for a permitted public HTTP test. ConnectAddr and ConnectPort identify the service it should connect to. An error reaching the listener and a negative SOCKS connection reply are different observations.

For a proxy requiring SOCKS5 username/password authentication, the documented constructor fields include AuthType => 'userpass', Username and Password.

A successful blocking constructor establishes the SOCKS connection, while an application request through the returned socket supplies the later application result. For an HTTPS destination, add verified destination TLS after SOCKS before sending that protocol’s request. Treat debug output as sensitive when credentials are involved.

Ũhoro ũhĩtĩte