-
Notifications
You must be signed in to change notification settings - Fork 13
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
Async Error Handling #13
Comments
Hello, thanks for your report! Mojo::IOLoop->start; after the request? Happy holidays, |
I took the code back to some basics. Basically if i set Async => 1 it seems to start the Mojo::IO Loop as i see an error But im still getting 'message' => 'Premature connection close' Hope you have a wonderful New Year and may 2017 be amazing for you |
Hello, thanks for getting back! Consider this example code, derived from yours: BEGIN { ++$ENV{TELEGRAM_BOTAPI_DEBUG} }
use Mojolicious::Lite;
use WWW::Telegram::BotAPI;
my $api = WWW::Telegram::BotAPI->new (
token => 'tok',
async => 1
);
any '/' => sub {
my $self = shift;
$self->render_later;
$api->getMe (sub {
my (undef, $tx) = @_;
unless ($tx->success) {
my $message = ($tx->error || {})->{message} || "something went wrong!";
app->log->error ("Error! HTTP message: $message");
app->log->error ("Please inspect \$tx->res->json for further information.");
return $self->render (json => { ok => \0 })
}
$self->render (json => $tx->res->json);
});
};
app->start; On my side, this works with no problem. Try it on your side and see if it works. On which platform are you currently using this module? |
Hi Robert
I tested your code and it worked went thought a process of elimination
through my code. The problem was i was declaring the BotAPI locally inside
the function when i declared the function globally then it fixed my
problem. Maybe worth noting on your sample code so that newbies like me
dont bother you by being stupid :-D
my $api = WWW::Telegram::BotAPI->new (
token => 'tok',
async => 1
);
Anyhow thank you for you time, i love open source and working with people
to make the world just that little bit better.
Hope you had a wonderful new year and didnt start the day with to much of a
hang over. At least one that this email would make worse :-D
Thanks for you great work
Craig
…On Sat, Dec 31, 2016 at 4:28 AM, Roberto Frenna ***@***.***> wrote:
Hello,
thanks for getting back!
Consider this example code, derived from yours:
BEGIN { ++$ENV{TELEGRAM_BOTAPI_DEBUG} }
use Mojolicious::Lite;use WWW::Telegram::BotAPI;
my $api = WWW::Telegram::BotAPI->new (
token => 'tok',
async => 1
);
any '/' => sub {
my $self = shift;
$self->render_later;
$api->getMe (sub {
my (undef, $tx) = @_;
unless ($tx->success) {
my $message = ($tx->error || {})->{message} || "something went wrong!";
app->log->error ("Error! HTTP message: $message");
app->log->error ("Please inspect \$tx->res->json for further information.");
return $self->render (json => { ok => \0 })
}
$self->render (json => $tx->res->json);
});
};
app->start;
On my side, this *works* with no problem. Try it on your side and see if
it works.
On which platform are you currently using this module?
Thanks, and happy new year to you too!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD7OV5tyzPFJmwsThmbEHilFNFyLYToBks5rNb3FgaJpZM4LT_7J>
.
|
That's interesting! Sorry for the delay -- I will do more research on that topic and I will probably include a note in the documentation. Thank you for being a great, collaborative user, and may you have a fantastic year too! |
Hi there seems to be a problem when it comes to using Async im using your default example, and im getting some strange errors
As you can see the PAYLOAD is being sent
PAYLOAD = [
"https://api.telegram.org/botXXXXXXXXX/sendMessage",
"json",
{
"chat_id" : 1XXXXXXXX,
"text" : "Hello"
}
]
But if i dump the $tx i see this error 'message' => 'Premature connection close'
$VAR1 = bless( {
'events' => {},
'res' => bless( {
'content' => bless( {
'headers' => bless( {
'headers' => {}
}, 'Mojo::Headers' ),
'events' => {
'read' => [
sub { "DUMMY" }
]
},
'read' => $VAR1->{'res'}{'content'}{'events'}{'read'}[0]
}, 'Mojo::Content::Single' ),
'error' => {
'message' => 'Premature connection close'
},
'state' => 'finished',
'finished' => 2,
'events' => {}
}, 'Mojo::Message::Response' ),
'completed' => 1,
'req' => bless( {
If i turn of async = 0 then the message gets thought.
Thanks
dexter
The text was updated successfully, but these errors were encountered: