Hello,

so I have put together test case with issue on route static: function which
probably does not serve correct response when file is not present, even
route-run break: does not help. I have tried different clients, but all of
them does not receive response. I have attached log from uWSGI, wget and
settings without app itself as it happens also without app. I was trying to
find responsible part in static.c
https://github.com/unbit/uwsgi/blob/uwsgi-2.0/core/static.c#L541 but I am
not entirely sure if that is why it does not send response as uWSGI log
looks like response is send - but maybe just empty? Could someone clarify
how this should behave?

Thank you,
Zdenek

$ uwsgi --ini test.ini
[uWSGI] getting INI configuration from test.ini
*** Starting uWSGI 2.0.14 (64bit) on [Sun Apr  2 09:59:55 2017] ***
compiled with version: 4.6.3 on 25 March 2017 08:18:51
os: Linux-3.2.0-120-generic #163-Ubuntu SMP Tue Dec 20 15:12:28 UTC 2016
nodename:
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
*** dumping internal routing table ***
[rule: 0] subject: path_info regexp: ^/static/(.*) action:
static:webapp/static/$1
*** end of the internal routing table ***
your processes number limit is 62734
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:8070 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:44951 (port auto-assigned) fd
3
Python version: 2.7.12 (default, Jul 18 2016, 14:59:49)  [GCC 4.6.3]
*** Python threads support is disabled. You can enable it with
--enable-threads ***
Python main interpreter initialized at 0x1e36730
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 474688 bytes (463 KB) for 3 cores
*** Operational MODE: preforking ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 27266)
spawned uWSGI worker 1 (pid: 27267, cores: 1)
spawned uWSGI worker 2 (pid: 27268, cores: 1)
spawned uWSGI worker 3 (pid: 27269, cores: 1)
*** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
spawned uWSGI http 1 (pid: 27270)
--- no python application found, check your startup logs for errors ---

------------------------ This one is okay

{address space usage: 53108736 bytes/50MB} {rss usage: 5394432 bytes/5MB}
[pid: 27268|app: -1|req: -1/1] 127.0.0.1 () {30 vars in 345 bytes} [Sun
Apr  2 09:59:59 2017] GET /ERROR => generated 21 bytes in 0 msecs (HTTP/1.1
500) 2 headers in 83 bytes (0 switches on core 0)


I guess that here is somewhere bug in serving static files via route
------------------------ From here client did not receive response
(headers 0 an ZERO Bytes served)
{address space usage: 53108736 bytes/50MB} {rss usage: 5615616 bytes/5MB}
[pid: 27268|app: -1|req: -1/2] 127.0.0.1 () {30 vars in 373 bytes} [Sun
Apr  2 10:00:13 2017] GET /static/missing_file => generated 0 bytes in 0
msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
{address space usage: 53108736 bytes/50MB} {rss usage: 5722112 bytes/5MB}
[pid: 27268|app: -1|req: -1/3] 127.0.0.1 () {30 vars in 373 bytes} [Sun
Apr  2 10:00:14 2017] GET /static/missing_file => generated 0 bytes in 0
msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
{address space usage: 53108736 bytes/50MB} {rss usage: 5394432 bytes/5MB}
[pid: 27269|app: -1|req: -1/4] 127.0.0.1 () {30 vars in 373 bytes} [Sun
Apr  2 10:00:16 2017] GET /static/missing_file => generated 0 bytes in 0
msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
^CSIGINT/SIGQUIT received...killing workers...
gateway "uWSGI http 1" has been buried (pid: 27270)
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
goodbye to uWSGI.



WGET LOG
----------------


-----------------------HERE is response with headers corectly served
$ wget http://localhost:8070/ERROR
--2017-04-02 09:59:59--  http://localhost:8070/ERROR
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8070... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2017-04-02 09:59:59 ERROR 500: Internal Server Error.


-----------------------HERE is response not received (also no headers) -
client is trying it again/
$ wget http://localhost:8070/static/missing_file
--2017-04-02 10:00:13--  http://localhost:8070/static/missing_file
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8070... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

--2017-04-02 10:00:14--  (try: 2)  http://localhost:8070/static/missing_file
Connecting to localhost (localhost)|127.0.0.1|:8070... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

--2017-04-02 10:00:16--  (try: 3)  http://localhost:8070/static/missing_file
Connecting to localhost (localhost)|127.0.0.1|:8070... connected.
HTTP request sent, awaiting response... No data received.
Retrying.



#uWSGI settings under uwsgi 2.0.14 under pip, running python2.7, with pcre
$cat test.ini
[uwsgi]
strict = true
http = 0.0.0.0:8070
master = true
processes = 3
stats = 127.0.0.1:9191
memory-report = true
buffer-size = 50000
add-header = Test: test
route = ^/static/(.*) static:$(PWD)/static/$1
2017-03-31 9:35 GMT+02:00 zd nex <zdnex...@gmail.com>:

> Hello,
>
> well I have tried that, but I have made very simple settings which is like
> this and it looks too me that response is never served to client. When I
> use wget - it tries to get response several times, but is not served.
> Firefox does same stuff then complains that request was not finished.
> Chrome says that it got ERR_EMPTY_RESPONSE without headers and other stuff.
>
> [uwsgi]
> strict = true
> http-timeout = 120
> socket-timeout = 120
> http = 0.0.0.0:8070
> master = true
> threads = 4
> offload-threads = 2
> processes = 3
> stats = 127.0.0.1:9191
> memory-report = true
> buffer-size = 50000
> single-interpreter = true
> route = ^/static/(.*) static:$(PWD)/static/$1
> route-run = break:404 Not Found
>
> 2017-03-30 22:28 GMT+02:00 Roberto De Ioris <robe...@unbit.it>:
>
>>
>> > Hello,
>> >
>> > we are using uWSGI for some time on pripravto.cz project for
>> > joiners/furniture makers. It works quite nice, we mostly like options
>> and
>> > stats, and error logging. Currently we wanted to improve serving of
>> static
>> > files (we are currently serving them through app) have tried to use
>> serve
>> > static files. We have tried option static-map= which works quite nice,
>> but
>> > we need to control access to files a little so we have tried route
>> option.
>> > When file is present it works quite nice. But when file is not present,
>> it
>> > gets called several times (we are not sure why). It seems that it is not
>> > possible to server error 404? It just recursively calls several times
>> and
>> > under HTTPS it actually does not server response to client. Just this
>> one
>> > line makes it to behave this way. If we remove it > serving is done by
>> our
>> > app and it is okay.
>> >
>> > route = ^/static/(.*) static:$(PWD)/static/$1
>> >
>> >
>> > We were using with uwsgi 2.0.14, python2.7.12, build with pcre, we have
>> > single interpreter option, threads, processes, master process a
>> > offloading.
>> > All this is under ubuntu12.04 Is there a way how this can be stopped, or
>> > are we doing something wrong? Bellow there is log for accessing file
>> which
>> > is in directory and then again which is not there. We have actually
>> wanted
>> > to use route-labels and other routing stuff, but it turns out, that it
>> > behaves in same way.
>> >
>> > Anyway, thanks for great project, which is fairly easy to use and just
>> > works.
>> >
>> >
>> >
>> > ####FIRST requests served via 304 and offload when file is present
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24731648
>> > bytes/23MB} [pid: 17381|app: -1|req: -1/6] 127.0.0.1 () {44 vars in 878
>> > bytes} [Sat Mar 25 13:55:57 2017] GET /static/js/utils.js => generated
>> > 71231 bytes in 0 msecs via offload() (HTTP/1.1 200) 2 headers in 88
>> bytes
>> > (0 switches on core 0)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24612864
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/7] 127.0.0.1 () {44 vars in 911
>> > bytes} [Sat Mar 25 13:56:07 2017] GET /static/js/utils.js => generated 0
>> > bytes in 0 msecs (HTTP/1.1 304) 0 headers in 29 bytes (0 switches on
>> core
>> > 3)
>> >
>> >
>> > ####File is not in directory > here it just gets called several times
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24776704
>> > bytes/23MB} [pid: 17381|app: -1|req: -1/8] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 1)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24641536
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/9] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 2)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24526848
>> > bytes/23MB} [pid: 17382|app: -1|req: -1/10] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24563712
>> > bytes/23MB} [pid: 17382|app: -1|req: -1/11] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24666112
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/12] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 1)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24690688
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/13] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 1)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24694784
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/14] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 3)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24694784
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/15] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24739840
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/16] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 2)
>> > {address space usage: 468115456 bytes/446MB} {rss usage: 24743936
>> > bytes/23MB} [pid: 17378|app: -1|req: -1/17] 127.0.0.1 () {40 vars in 813
>> > bytes} [Sat Mar 25 13:56:54 2017] GET /static/js/us => generated 0 bytes
>> > in
>> > 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 1)
>> >
>> > --
>> > Regards,
>> >
>> > Zdenek & Michal
>> >
>> >
>>
>>
>> Hi, the retrying og the static files is pretty strange, it looks like the
>> client is triggering the retry when it gets 500.
>>
>> By the way, there is a plugin called notfound in the project that you can
>> use as a fallback, but i think in your specific case the
>>
>> break:404 Not Found
>>
>> routing action would be more suited:
>>
>> route = ^/static/(.*) static:$(PWD)/static/$1
>> ; if the previous rule fails, returns 404
>> route-run = break:404 Not Found
>>
>>
>> --
>> Roberto De Ioris
>> http://unbit.com
>> _______________________________________________
>> uWSGI mailing list
>> uWSGI@lists.unbit.it
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>>
>
>
>
> --
>
> --
> S pozdravem,
>
> Zdeněk Dlauhý
>
> Email:supp...@pripravto.cz
> Mobil: +420 702 549 370 <+420%20702%20549%20370>
> Web: www.pripravto.cz
>
_______________________________________________
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to