Hello,

I just tried the way you suggest but got the same error. Seems to me that 
UA goes out of scope and dies. Is there a way to prevent this

Regards, 

IA

On Tuesday, April 26, 2016 at 7:39:19 PM UTC-4:30, Scott Wiersdorf wrote:
>
> Is there a reason you can't do something like this?:
>
> sub res1{
>   my $c=shift;
>   $c->ua->post('http://www.example.com', sub {
>     my ($uax, $txx) = @_;
>      $c->app->log->debug(Dumper($txx));
>   });
>
>   $c->render(status=>200,data=>'');
> }
>
> The way you're doing it, the transaction goes out of scope which is 
> probably why you get the premature connection close. In the above example, 
> the post() will return immediately, allowing the render() to execute next. 
> The post() response will be handled asynchronously whenever it comes back. 
>
> Scott
>
> On Tuesday, April 26, 2016 at 5:57:17 PM UTC-6, Iván Aponte wrote:
>>
>>  Hello, 
>>
>> I have the following problem. I have a service which gets call, it must 
>> answer with 200, close the connection and post to another web service. If I 
>> do it in a non-blocking way premature closing occurs. 
>>
>> E.g. : 
>>
>> sub res1{
>>   my $c=shift;
>>    $c->render(status=>200,data=>'');
>>    my $ua = Mojo::UserAgent->new;
>>    my $tx = $ua->build_tx(POST => 'http//www.example.com');
>>    $ua->start($tx=> sub{
>>     my ($uax, $txx) = @_;
>>      $c->app->log->debug(Dumper($txx));
>>    });
>> }
>>
>>
>>
>> Is there a way to make a post after rendering without blocking ?
>>
>>
>> Thanks, 
>>
>> IA
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to