unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 692 forks source link

`http11-socket` will cause port binding failed #1365

Open virusdefender opened 8 years ago

virusdefender commented 8 years ago

error output

*** Starting uWSGI 2.1-dev-c0d1e76 (64bit) on [Wed Sep 21 06:34:21 2016] ***
compiled with version: 5.4.0 20160609 on 21 September 2016 06:30:56
os: Linux-3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:15 UTC 2016
nodename: e69e483e09fb
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /app/skyview
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /app/skyview
your processes number limit is 524288
your memory page size is 4096 bytes
detected max file descriptor number: 524288
building mime-types dictionary from file /etc/mime.types...552 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:9000 fd 3
bind(): Permission denied [core/socket.c line 232]

uwsgi.ini

[uwsgi]
http=0.0.0.0:9000
chdir=/app/skyview
master=true
processes=2
threads=2
wsgi-file = skyview/wsgi.py
static-map = /=/app/dist
static-index = index.html
http11-socket = true

But if you replace http11-socket = true by

http-keepalive = true
add-header = Connection: Keep-Alive

uwsgi can start well, but keep-alive seems not working

uWSGI http bound on 0.0.0.0:9000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:49762 (port auto-assigned) fd 3
Python version: 3.5.2 (default, Jul  5 2016, 12:43:10)  [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x1a9c740
python threads support enabled
$ telnet 25.25.205.32 9000
Trying 25.25.205.32...
Connected to 25.25.205.32.
Escape character is '^]'.
GET / HTTP/1.1

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1725
Last-Modified: Tue, 20 Sep 2016 12:40:08 GMT
Connection: Keep-Alive

<!DOCTYPE html><html><head>
...
</html>Connection closed by foreign host.

uwsgi is started by supervisor, config file is

[program:uwsgi]
user = nobody
command = /app/deploy/server.sh
directory = /app/skyview
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

server.sh

exec uwsgi --ini /app/deploy/uwsgi.ini

if you start uwsgi with root user and http11-socket = true, uwsgi will send empty response

xxx.com didn’t send any data.
ERR_EMPTY_RESPONSE
unbit commented 8 years ago

http11-socket does not work this way. It is like http-socket but with persistent support (so you need to pass it a socket). Combining the http router wth http11-socket is not supported (it is meant to be placed behind nginx that supports http/1.1 upstreams), unless you set te http router in 'dumb' mode (it basically became a tcp proxy).

virusdefender commented 8 years ago

Thanks!

Now i get the reason why http11-socket do not work.

I'll trying to get http-keepalive to work.