"Premature connection close" errors with final Mango request in IOLoop delay

45 views
Skip to first unread message

Heiko Jansen

unread,
Jul 6, 2016, 7:05:54 AM7/6/16
to Mojolicious
I´m trying to chain a bunch of requests to a MongoDB server by utilizing Mojo::IOLoop->delay; 
unfortunately the last Mango command (and only the last one) always returns the error "Premature connection close".

With MANGO_DEBUG=1 I can see that the last command gets written to the MongoDB connection and in the the mongod output I can also see that it is retrieved and executed.
But Mango never logs the response data.

Apparently it does not matter which command is used as the last one.
I tried to provide a minimal test case with dummy commands here: https://gist.github.com/heikojansen/3aec5349e7fcc009a420a69a3f8271eb

I don´t know if it´s a bug in Mango or if I´m lacking some vital understanding how the event loop works...

Thx in advance for any hints and suggestions!
- Heiko

Alexey Stavrov

unread,
Jul 6, 2016, 7:23:28 AM7/6/16
to Mojolicious
Your local variable $m destroyed in third step of delay. Add something like "$c->stash(m => $m);" before IO::Loop->delay;

среда, 6 июля 2016 г., 16:05:54 UTC+5 пользователь Heiko Jansen написал:

Heiko Jansen

unread,
Jul 6, 2016, 8:24:16 AM7/6/16
to Mojolicious


Am Mittwoch, 6. Juli 2016 13:23:28 UTC+2 schrieb Alexey Stavrov:
Your local variable $m destroyed in third step of delay. Add something like "$c->stash(m => $m);" before IO::Loop->delay;

Damn. Again. ;-(
Well, the demo in the gist can be fixed by pulling "my $m = Mango->new();" out of the anonymous sub so it´ll survive the request.

Given that I get the same error within the real app code it´s quite probably the same problem. 
Since the code there is a bit more complicated it´s not quite as obvious where things go wrong so I´ll have to dig in and see what variable goes out of scope where.
But now that I know what I´m looking for...

Thanks for the hint!
- Heiko

sri

unread,
Jul 6, 2016, 1:26:53 PM7/6/16
to Mojolicious
Please note that Mango is not on-topic on this list anymore.

--
sebastian

sri

unread,
Jul 6, 2016, 1:32:19 PM7/6/16
to Mojolicious
Please note that Mango is not on-topic on this list anymore.

In fact, i would strongly advice against using MongoDB if you have a choice, it is bad software and will eat your data. And i'm saying that as the original author of Mango.

--
sebastian 
Reply all
Reply to author
Forward
0 new messages