in reply to Re: HTTP Request and Threads
in thread HTTP Request and Threads

That's a good idea!

I think that LWP::UserAgent will only load the SSL libraries once it encounters an https URL. To be really sure, you can try to load LWP::UserAgent only from within each thread. This has other drawbacks, but at least for diagnosis, maybe it helps:

#use LWP::UserAgent; # don't load this in the outside program my $a = threads->create(sub () { require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00); };

Thinking more about this, I'm less confident that this approach changes much, at least if the C part of the ssl library still only gets initialized once, but as it's a small change, I think it's worth a try.

Replies are listed 'Best First'.
Re^3: HTTP Request and Threads
by banhmi (Initiate) on Sep 13, 2018 at 21:13 UTC

    Thanks for the response. Loading LWP::UserAgent from within the thread unfortunately doesn't help. But from your comment, I did try using an http URI and that seems to work just fine. So at least I think suspecting SSL library seems to be the right way to turn!