[Mojolicious] Forward-streaming a streaming HTTP resource ("processing proxy")

2015-09-21 Thread Heiko Jansen
Dear all, basically what I want to achieve is this: 1. App gets an "EventSource" javascript request with some query param from client 2. App sends a HTTP request to a backend server with that query 3. Backend server sends blocks of data in a streaming, long-running response (HTTP

[Mojolicious] Re: Forward-streaming a streaming HTTP resource ("processing proxy")

2015-09-21 Thread Heiko Jansen
Am Montag, 21. September 2015 18:27:49 UTC+2 schrieb sri: > > This might be helpful. > > > http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Streaming-response > I´m afraid it isn´t. Unless I´m just acting blockheaded and miss something glaringly obvious, that is the part of the proble

[Mojolicious] Re: Forward-streaming a streaming HTTP resource ("processing proxy")

2015-09-21 Thread Heiko Jansen
Am Montag, 21. September 2015 22:56:52 UTC+2 schrieb sri: > > Just replace "$tx = $ua->start($tx);" with "$ua->start($tx => sub { my > ($ua, $tx) = @_; ... });" and buffer incoming bytes. > That´s what I thought I did in "proxy2.pl". Am Montag, 21. September 2015 23:01:06 UTC+2 schrieb sri: >

[Mojolicious] Request-ID logging possible with asynchronous request handling?

2015-12-02 Thread Heiko Jansen
I believe this question has been asked before and the person who asked was told that what he wanted wasn´t feasible - but I cannot right now find the conversation. Also, maybe some influencing factor has changed so perhaps nowadays there is a solution possible for what follows? Our HTTP front e

[Mojolicious] Re: Mojolicious::Lite websocket connection problem

2016-03-03 Thread Heiko Jansen
According to https://metacpan.org/diff/file?target=SRI%2FMojolicious-6.23%2F&source=SRI%2FMojolicious-6.22%2F#lib/Mojo/Transaction/WebSocket.pm up to v6.22 an incoming protocol selection ("Sec-WebSocket-Protocol" header, 3rd argument to "new WebSocket()" in your client) was automatically copied t

[Mojolicious] Re: Mojo::Lite + AJAX exception handling / exception design pattern

2016-03-23 Thread Heiko Jansen
Throwing the exception leads to a response code "500" for the ajax request; since code 500 signals an error the "fail" handler for the ajax request get´s triggered. That of course does not mean that the content returned from the mojo server is rendered in your page; it was an ajax request after

[Mojolicious] Re: Mojo::Lite + AJAX exception handling / exception design pattern

2016-03-23 Thread Heiko Jansen
Am Mittwoch, 23. März 2016 15:57:32 UTC+1 schrieb ddal...@gmail.com: > A more general question, is this a good way to handle exceptions caught in > mojo callback functions? An alternative would be to not throw an > exception and instead, render error data that gets returned to the .ajax > .

[Mojolicious] Re: Mojo::Lite + AJAX exception handling / exception design pattern

2016-03-24 Thread Heiko Jansen
Am Mittwoch, 23. März 2016 15:57:32 UTC+1 schrieb ddal...@gmail.com: > > > 1) In the Mojo callback function (/price route), invoking > Mojo::Exception->throw(message) triggers the rendering of the > exception.development.html.ep template from the __DATA__ section. In the > template, the thrown

[Mojolicious] Re: Validation before posting to an external site

2016-04-06 Thread Heiko Jansen
Am Dienstag, 5. April 2016 18:42:03 UTC+2 schrieb Stuart Dodds: > > However, once the validation has passed, I am not sure how to then issue > the original POST request to the external site as well as redirecting the > user along with the request. Is there a way I can do this? > 1) You could se

[Mojolicious] Re: Validation before posting to an external site

2016-04-06 Thread Heiko Jansen
Am Mittwoch, 6. April 2016 12:18:01 UTC+2 schrieb Stuart Dodds: > > First of all, it never even crossed my mind to try to change the form > method to GET until you mentioned it in your second point. So I tried it > out and it worked! Now I can build the url after the successful validation > and

[Mojolicious] Re: Using IO::Loop on websocket connection

2016-05-04 Thread Heiko Jansen
Am Montag, 2. Mai 2016 17:20:47 UTC+2 schrieb Matija Papec: > > > I want to read from redis in non-blocking way and delay() looks like first > choice for this kind of task (event callbacks are closures to session > related variables). > Using delay() for non-blocking handling of requests (or mor

Re: [Mojolicious] How to send a websocket message from a post?

2016-05-10 Thread Heiko Jansen
Am Montag, 9. Mai 2016 04:58:21 UTC+2 schrieb Lachlan Deck: > If I do need multi-threaded support in future, where would I look? > Be aware that there´s usually no "multi-threading" in the context of Mojolicious, but asynchronous processing in multiple processes. The solution given should wor

[Mojolicious] Re: Basic non-Lite WebSocket Application

2016-05-15 Thread Heiko Jansen
Am Sonntag, 15. Mai 2016 18:17:47 UTC+2 schrieb john: > > I have written mojo lite based websocket applications but am having > problems with my first attempt at a full application: > > https://github.com/john-/mojo_inotifier > Try changing Actions.pm, L13 from my $self => shift; to my $se

[Mojolicious] Re: translate curl command to Mojo::UserAgent

2016-05-23 Thread Heiko Jansen
Am Donnerstag, 19. Mai 2016 20:46:20 UTC+2 schrieb Jim Hall: > > > It looks like the following line is useless: > IO::Socket::SSL::set_defaults(SSL_verify_mode => 'VERIFY_NONE'); > I´m pretty sure VERIFY_NONE should be a constant, not a string?! - Heiko -- You received this message because you

[Mojolicious] Re: Mojolicious flow

2016-05-23 Thread Heiko Jansen
Don´t really understand from your description what happens where and which component logged what - but since that logging output does not look as if it was written by Mojolocious my first question would be: could there be any reverse proxy involved, rewriting incoming requests for an upstream M

[Mojolicious] Re: Keeping Route Logic Alive

2016-05-24 Thread Heiko Jansen
Am Dienstag, 24. Mai 2016 13:51:42 UTC+2 schrieb john: > > What confuses me is that I was previously using Mojo::Pg::PubSub and > this works: > I think it works like this: https://metacpan.org/source/SRI/Mojo-Pg-2.27/lib/Mojo/Pg/PubSub.pm#L14 keeps a reference to the callback inside the Mojo::P

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

2016-07-06 Thread Heiko Jansen
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 conne

[Mojolicious] Re: "Premature connection close" errors with final Mango request in IOLoop delay

2016-07-06 Thread Heiko Jansen
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

[Mojolicious] Re: Mojo::Reactor::Poll: I/O watcher failed: Can't call method "build_tx" on an undefined value at C:/Perl64/site/lib/Mojo/Server.pm line 23.

2016-10-11 Thread Heiko Jansen
Am Freitag, 7. Oktober 2016 21:52:26 UTC+2 schrieb petra: > > [...] > And do instruction from this page > http://mojolicious.org/perldoc/Mojolicious/Guides/Growing > > But after section *Simplified application script *and running test, I got > such error: > > t/login.t .. Mojo::Reactor::Poll: I/O

[Mojolicious] Re: writing chunks in non-blocking mode

2016-10-13 Thread Heiko Jansen
I´m not sure if I understand your workflow correctly but how about this: for every row processed send a small JSON documents to the browser which contains information on the worksheet, row and row status and then have some JavaScript code in the browser assemble and update the correct HTML tabl

[Mojolicious] Re: writing chunks in non-blocking mode

2016-10-21 Thread Heiko Jansen
Am Freitag, 14. Oktober 2016 01:06:57 UTC+2 schrieb Steve Barnsley: > > I tried 'wrapping' the list of calls to the various templates in a > $c->delay(@list); structure, this causes the first template (table) to > execute in its entirety but it never starts the second entry in the list > (even t

Re: [Mojolicious] Nginx and Hypnotoad proxy correct config

2017-02-16 Thread Heiko Jansen
Did not try to verify this, but if I understand your example config correctly it may be related to the way nginx processes "location" directives. To quote http://nginx.org/en/docs/http/request_processing.html nginx first searches for the most specific prefix location given by literal > strings

[Mojolicious] Re: Incorrect originating IP from $c->tx->remote_address() on requests via nginx reverse proxy

2017-02-16 Thread Heiko Jansen
As far as I understand it, this is what happens: Step 1: http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_header => "Defines the request header field whose value will be used to replace the client address." So in your config you tell nginx to treat the value of the header " X-

[Mojolicious] Re: Incorrect originating IP from $c->tx->remote_address() on requests via nginx reverse proxy

2017-02-17 Thread Heiko Jansen
Hmmm. I have "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" in my nginx conf and apparently no other related directives. Starting the Mojo server via MOJO_REVERSE_PROXY=1 carton exec -- morbo script/app and having these statements in my code: warn " remote addr: " . $c-

[Mojolicious] Updating config object when config database is updated

2017-05-17 Thread Heiko Jansen
Hi *, we're working on an app with some extensive config data which also needs some preprocessing (merging defaults etc.) to become usable. We use a plugin ("register" method) to initialise a config object on app start and keep it around, as recreating the config on every incoming request would

[Mojolicious] Re: Mojo::Test to follow redirect?

2017-05-28 Thread Heiko Jansen
According to the example at https://metacpan.org/pod/Test::Mojo#ua I´d say you´re doing it right. I wonder, however, how uncommenting that line of code can lead to this error message: "Can't connect: nodename nor servname provided, or not known" - which is apparently not part of Mojolicious its

[Mojolicious] Re: Mojo::Test to follow redirect?

2017-05-28 Thread Heiko Jansen
Am Sonntag, 28. Mai 2017 19:34:11 UTC+2 schrieb iaw4: > > > my app redirects to http://auth.localhost:3000/index , > Well, on my OpenSUSE box neither the "host" nor the "nslookup" (or "dig") commands return an IP address for "auth.localhost" (they do, of course, for "localhost"), so I´d say that

[Mojolicious] Re: Mojo::Test to follow redirect?

2017-05-29 Thread Heiko Jansen
Am Montag, 29. Mai 2017 01:25:13 UTC+2 schrieb iaw4: > so here is one solution, although this one does not work in chrome: Add > 'localhost.test' and 'auth.localhost.test' at the end of 127.0.0.1 > localhost in /etc/hosts and `# morbo -v appname -l > http//localhost.test:3000`. now, http://

[Mojolicious] url_for() and URI-escaping chars in placeholder values

2017-07-09 Thread Heiko Jansen
I need to generate links within an app based on data from an external data source. It contains data for a list of categories, and the category names may contain almost any character including slashes. Given this minimal example app: #!/usr/bin/env perl use Mojolicious::Lite; get '/:cat' =>

[Mojolicious] Question regarding Mojolicious v7.49 changes to M:I:Delay

2017-11-10 Thread Heiko Jansen
Mojolicious v7.49 took us by surprise because of the changes to Mojo::IOLoop::Delay. We have a fairly large code base dealing extensively with gathering data from a wide variety of back end systems (for displaying in a web portal). Replacing the catch() method with the new one which does not re

[Mojolicious] Documentation "bug"

2017-11-22 Thread Heiko Jansen
Hi, just saw that POD in Mojo::Template says: <%= Perl expression, replaced with result %> <%== Perl expression, replaced with XML escaped result %> while POD in Mojolicious::Guides::Rendering says: <%= Perl expression, replaced with XML escaped result %> <%== Perl expression, replaced with res

Re: [Mojolicious] Documentation "bug"

2017-11-23 Thread Heiko Jansen
Am Mittwoch, 22. November 2017 17:27:51 UTC+1 schrieb Dan Book: > > When the auto_escape option is set on Mojo::Template, it reverses this > behavior; auto_escape is set by default for the EPRenderer template > handler, which the rendering guide is referring to. I agree it is a bit > confusing b

Re: [Mojolicious] Re: Mojo::UserAgent and large files

2018-08-17 Thread Heiko Jansen
Hmm, there's no access to the controller ($c) and no reference to it kept in the fullfillment or rejection callbacks. I'd guess it is therefore garbage collected once you leave "welcome" and the client connection thus closed immediately. hth, heiko -- You received this message because you are

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Heiko Jansen
I do not know of a non-ugly way either but if you are okay with a hacky and possibly fragile solution you might get away with adding: $ua->on(start => sub { my ($ua, $tx) = @_; $tx->req->{'start_buffer'} =~ s/([&?]s=)%5E/$1^/o; }); Poking into internals usually means one day you'll get w

[Mojolicious] Re: max_message_size

2018-12-24 Thread Heiko Jansen
Am Montag, 3. Dezember 2018 10:29:49 UTC+1 schrieb Mikhail: > > I try to set *$c->req->max_message_size(0) *per ONE route/action. > > This is not work. How to upload big data but not whole APP for? > Can't actually answer your question outright, but maybe have two ideas for things you could try:

[Mojolicious] Re: Event driven based on syslog messages

2019-04-26 Thread Heiko Jansen
Bit late to the party, but anyhow If you tell rsyslogd to send output to a socket (using omuxsock), you can then use Mojo::IOLoop::Client to connect() to a socket via the "path" argument. Afterwards you can make use of the IOLoop to process events for reading from the socket. That's what you

[Mojolicious] Re: program locked up upon Mojo::Reactor::EV: Timer failed

2019-04-26 Thread Heiko Jansen
Admittedly more of a guess, but https://metacpan.org/pod/Mojo::Transaction#result is documented to "die" on connection errors, so maybe wrap that in an "eval" or otherwise modify the order of "error" / "is_success" checks? -- You received this message because you are subscribed to the Google G

[Mojolicious] Re: Event driven based on syslog messages

2019-05-30 Thread Heiko Jansen
Sorry, completely missed your follow-up... I'd say the synopsis of Mojo::IOLoop mostly shows what to do. Never tried it myself, but something along these lines should work: use Mojo::IOLoop; my $id = Mojo::IOLoop->client({ path => '/tmp/myapp.sock' } => sub { my ($loop, $err, $stream) = @_;

Re: [Mojolicious] Set correct rights to unix socket with Mojo::Server::Daemon

2019-05-30 Thread Heiko Jansen
What about simply running your Mojo app under the same user or a user with the same user group as used for nginx? Otherwise, what about using Perl's "umask" builtin in your app start script to set the appropriate value and probably reset it after the app started? -- You received this message be

[Mojolicious] Re: With Mojo::IOLoop's delay, timer, and recurring, can I use them in a promises's "then" clause?

2020-09-30 Thread Heiko Jansen
I actually don't know about any pitfalls when using Mojo::IOLoop's delay etc. methods within "then" clauses, but from my (limited) experience I'd suggest to avoid mixing traditional IOLoop methods and promises if only because it makes it even harder to follow the code flow. To me it looks like