python - Writing to a uWSGI unix socket -
python - Writing to a uWSGI unix socket -
i have python wsgi app served uwsgi behind nginx. nginx listens on network , forwards requests uwsgi unix socket located in /tmp/uwsgi.socket
.
now, i'm trying emulate i'm speculating nginx when talking socket. i've tried next using python:
import socket uwsgi_socket_address = "/tmp/uwsgi.sock" socket_client = socket.socket(socket.af_unix, socket.sock_stream) socket_client.connect(uwsgi_socket_address) msg = "get /index http/1.1\r\n" socket_client.sendall(msg)
i error in return
/usr/lib/python2.7/socket.pyc in meth(name, self, *args) 222 223 def meth(name,self,*args): --> 224 homecoming getattr(self._sock,name)(*args) 225 226 _m in _socketmethods: error: [errno 32] broken pipe
1) i'm trying possible socket , uwsgi? if missing work?
2) there python utility can help me in crafting text http requests, rather querying server on behalf? :
>>> import somehttplib >>> http = somehttplib() >>> request = http.get('/index') >>> request.text=='get /index http/1.1\r\n' true
you cannot talk http server speaking 'uwsgi' protocol. uwsgi protocol simple binary serialization format arrays , dictionaries. if want speak http uwsgi server have configure speak http --http-socket instead of --socket.
you can have both in same instance with:
uwsgi --http-socket <address1> --socket <address2> ...
eventually can implement uwsgi serializer few lines.
this illustration of parser (you need opposite obviously):
https://github.com/unbit/blastbeat#uwsgi
here find specs:
http://uwsgi-docs.readthedocs.org/en/latest/protocol.html
python sockets http uwsgi
Comments
Post a Comment