Contributed by Anonymous Monk on Nov 04, 2001 at 01:42 UTC
Q&A  > HTTP and FTP clients


Well, I had in mind to let my program connect to a server through a proxy.

For this, I'm using LWP::UserAgent. Though my problem is that regardless of what proxy I use, I cant connect out. If I "remove" the proxy, everything works fine, but not with it.

I believe the problem has something to do with the "no_proxy" definition.

$ua->proxy('http', ''); $ua->no_proxy('');

Anyone have any idea of what Im doing wrong?

Thanks in advance

Edited by footpad, ~Sun Nov 25 04:28:22 2001 (GMT)

Answer: Why cant I connect through a proxy using perl?
contributed by IlyaM

I don't know what the reason of your problem but often turning on debug trace in LWP helps to debug problems with LWP.

Try to add

use LWP::Debug qw(+);

into you program and see what happens when it tryes to talk with proxy. See LWP::Debug docs for more info about LWP debug tracing.

Answer: Why cant I connect through a proxy using perl?
contributed by redbrick

Mmm... I am also new to this stuff, but while I was wandering around hacking deluge (a web stress tool, I found the following code:


where $ua is an instance of UserAgent. And in the UserAgent pod, I found that this command imports proxy settings from the following enviroment vars: http_proxy and ftp_proxy.

Hope that this works for you.

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.