-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR: Proxy connection failed - print details #29
Comments
Hi Pavel, happy new year! I'm very sorry for the late response but it's been a busy period -- thanks for using my module. So as you might know the entire proxy handling is done by I'll try to investigate this a bit further and see if I can accommodate your request, though. I'll let you know! |
This commit was made following a suggestion in #29 due to the way Mojo::UserAgent handles proxy errors. Long story short, when a connection to the specified proxy server fails, Mojo::UserAgent returns an opaque "Proxy connection failed" without returning the real reason of failure. This can be problematic when debugging, thus now this module extracts the real failure reason in debug mode. From a technical standpoint, this attaches an on "start" handler on the main `UserAgent` object which is invoked for each connection attempt made by the user agent. This includes `CONNECT` requests, and when that happens the module attaches an on "finish" handler to that connection which allows to extract the real failure reason.
Hey! I got great news. I was able to find a way to intercept the real reason of failure for proxy errors and I have pushed 2f6a791 (which will soon be in version 0.12 on CPAN) which will print these kind of failures when using debug mode (i.e. If you need the actual proxy failure in code and not when debugging, then you can retrieve the # assuming $api is a WWW::Telegram::BotAPI object
my $agent = $api->agent;
if ($agent->isa ('Mojo::UserAgent')) { # Only related to Mojo::UserAgent
$agent->on (start => sub {
my (undef, $tx) = @_;
# Skip all requests which are not proxy-related.
return unless $tx->req->method eq "CONNECT";
# Add an handler on completion.
$tx->on (finish => sub {
my $tx = shift;
if (my $error = $tx->error) {
# $error is an hash reference with "message" in it. Do whatever you need with that information.
say "Kaboom! ", $error->{message};
}
});
})
} Hope this has been useful. Feel free to reopen the issue if anything else comes up! Have a good day, |
Great, Roberto, thanks so much! |
Hi, Roberto. I think it would be nice to print proxy connection error more verbose.
Example.
The text was updated successfully, but these errors were encountered: