Skip to content
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

use just the echo_sleep and then proceed as normal? #71

Closed
fommil opened this issue Jul 11, 2017 · 2 comments
Closed

use just the echo_sleep and then proceed as normal? #71

fommil opened this issue Jul 11, 2017 · 2 comments

Comments

@fommil
Copy link

fommil commented Jul 11, 2017

Hi, I'm trying to use echo_sleep as a way to mock out some services with known worst case latency. My docker build is here https://github.com/fommil/docker-nginx-echo which seems to work fine.

However, this kind of config always returns empty contents

     location / {
        echo_sleep 0.1;
        root   /to/my/data;
     }

(obvs works without the echo_sleep, but no delay). I tried a hack of

    location / {
        echo_sleep 0.1;
        echo_location /raw/$query_string ;
    }

    location /raw {
        root   /to/my/data;
    }

but also not doing what I expect. Is there a way to just get the echo_sleep feature?

@fommil
Copy link
Author

fommil commented Jul 11, 2017

ok, this seems to be working for me

    location / {
        echo_sleep 0.1;
        echo_exec @raw;
    }

    location @raw {
        root   /to/my/data;
    }

so I change my question to... is this how I'm supposed to do it?

@agentzh
Copy link
Member

agentzh commented Jul 11, 2017

@fommil Both echo_sleep and root register a different "content handler" for that location. And in nginx, only one content handler is allowed in a single location. Use of ngx_echo's own directives work since they register the same single content handler of ngx_echo. This is nginx basics. To work around that, you should use the ngx_lua module instead, as in

location / {
    access_by_lua_block { ngx.sleep(0.1) }
    root /to/my/data;
}

@agentzh agentzh closed this as completed Jul 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants