Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: 500 error with LWP:UserAgent

by Loops (Curate)
on Nov 04, 2014 at 10:16 UTC ( #1106005=note: print w/replies, xml ) Need Help??


in reply to 500 error with LWP:UserAgent

Hi there!

Would like to help, but this is not a Perl question. As you said, changing the URL to another site, it-just-works. The problem is knowing what that payment system company expects; unfortunately their documentation seems to be private. You'll need a peek at the documentation or some help from them directly.

Update: Okay, have to apologize I guess, since I decided to try your code here anyway. It turns out with v5.18.4, i get your 500 error, and with v5.20.0 i get web content back saying that an error occurred (in Spanish). With the exact same copy of your code. Odd.

Update2: Wireshark revealed it was an SSL error causing the problem. Something must have changed in the Perl SSL module between v18 and v20. Anyway, if you change the ssl_opt to that given below, the code works in either version:

my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, SSL_v +ersion => 'TLSv1' });

You may want to look at the other SSL options as listed in the IO::Socket::SSL docs.

HTH

Replies are listed 'Best First'.
Re^2: 500 error with LWP:UserAgent
by RenardBleu (Sexton) on Nov 04, 2014 at 12:42 UTC
    Hi there,

    I tried your modification and it didnt change my case.

    I use
    perl v5.14.2
    LWP::UserAgent v6.06
    HTTP::Request v6.00
    IO::Socket::SSL 1.955

    Adding
    use Net::SSLeay; $Net::SSLeay::trace = 2;

    as suggested on stackoverflow : http://stackoverflow.com/questions/26732578/500-error-with-lwpuseragent produced the output
    DEBUG: .../IO/Socket/SSL.pm:449: socket not yet connected DEBUG: .../IO/Socket/SSL.pm:451: socket connected DEBUG: .../IO/Socket/SSL.pm:469: ssl handshake not started DEBUG: .../IO/Socket/SSL.pm:504: using SNI with hostname sis-t.redsys. +es DEBUG: .../IO/Socket/SSL.pm:527: set socket to non-blocking to enforce + timeout=10 DEBUG: .../IO/Socket/SSL.pm:550: ssl handshake in progress DEBUG: .../IO/Socket/SSL.pm:560: waiting for fd to become ready: SSL w +ants a read first DEBUG: .../IO/Socket/SSL.pm:570: handshake failed because socket did n +ot became ready Error: 500 Can't connect to sis-t.redsys.es:25443

      Well it's a puzzle for sure. I installed Perl and those modules with the same version you have, and it just worked with the updated code. The old code gave the same Net::SSLeay debug output as yours. There is some underlying difference between our setups obviously.

      There's a chance that changing the SSL version to this would help:

      SSL_version => 'TLSv1:!TLSv11:!TLSv12:!SSLv2:!SSLv3'

      The last two components are supposedly redundant. But in any case, that long version string wasn't needed here (with any of 3 machines).

      Update: Just as a debugging step, try adding random garbage to the string you pass into SSL_version. You should expect the following error, otherwise something is up in Denmark:

      Error: 500 invalid SSL_version specified
        May i ask for your perl -MIO::Socket::SSL -e 'print "$IO::Socket::SSL::VERSION\n"' version please ?

        I just was able to test on a machine with
        perl 5.14.2
        LWP:User::Agent 6.04
        IO::Socket::SSL 1.76
        Net::SSLeay 1.48 (while mine is 1.55)
        and it just worked fine (exact same code, I scp-ed it)
        One good news, one bad.

        Good news is we dont need to disturb Denmark government, i achieved the 500 invalid SSL_version specified with SSL_version='Garbage'

        Bad news is changing the SSL_version doesnt solve my problem at all.

        Could it be due to perl version ? (I cant change mine here :/)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1106005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-05-21 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?