๐ Hi, I'm Z.
Building AI at @hanzoai. Founded @luxdefi to increase economic freedom through decentralized access to private, quantum safe assets (QSAs). Saving endangered animals with @zoo-labs.
Say hi: curl zeekay.chat | sh
๐พ Easy websockets for bottle.
License: MIT License
mining/mining#89
Error:
<h1>Critical error while processing request: /stream/data/rwer</h1>Traceback (most recent call last):
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/gevent/pywsgi.py", line 508, in handle_one_response
self.run_application()
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/geventwebsocket/handler.py", line 76, in run_application
self.run_websocket()
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/geventwebsocket/handler.py", line 52, in run_websocket
self.application(self.environ, lambda s, h: [])
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/beaker/middleware.py", line 155, in __call__
return self.wrap_app(environ, session_start_response)
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/bottle.py", line 979, in __call__
return self.wsgi(environ, start_response)
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/bottle.py", line 974, in wsgi
start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info())
File "/home/avelino/.virtualenvs/mining/lib/python2.7/site-packages/beaker/middleware.py", line 154, in session_start_response
return start_response(status, headers, exc_info)
TypeError: <lambda>() takes exactly 2 arguments (3 given)
{'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.5',
'HTTP_CACHE_CONTROL': 'no-cache',
'HTTP_CONNECTION': 'keep-alive, Upgrade',
'HTTP_COOKIE': 'beaker.session.id=840c92edceec4c8580bd57722a46204f',
'HTTP_DNT': '1',
'HTTP_HOST': '127.0.0.1:8888',
'HTTP_ORIGIN': 'http://127.0.0.1:8888',
'HTTP_PRAGMA': 'no-cache',
'HTTP_SEC_WEBSOCKET_KEY': 'beXNjFDC61V0WqdPYPkSLg==',
'HTTP_SEC_WEBSOCKET_VERSION': '13',
'HTTP_UPGRADE': 'websocket',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0',
'PATH_INFO': '/stream/data/rwer',
'QUERY_STRING': 'page=1&',
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_PORT': '34933',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '/',
'SERVER_NAME': 'avelino-MacBookPro',
'SERVER_PORT': '8888',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
'beaker.get_session': <bound method SessionMiddleware._get_session of <beaker.middleware.SessionMiddleware object at 0x3f386d0>>,
'beaker.session': {'username': u'[email protected]', 'first_name': u'Thiago', 'last_name': u'Avelino', 'uid': u'AItOawkEk5CLcqdEN70kB8K9ysfCMy0mafnIjbQ', 'language': u'pt-br', 'profile_image': None, 'profile_url': None, 'profile_image_small': None, '_accessed_time': 1398189234.261992, 'email': u'[email protected]', '_creation_time': 1398189183.635779, 'screen_name': u'Thiago'},
'bottle.app': <bottle.Bottle object at 0x3de5950>,
'bottle.get': <bottle.FormsDict object at 0x405bdd0>,
'bottle.raw_path': '/data/rwer',
'bottle.request': <LocalRequest: GET http://127.0.0.1:8888/stream/data/rwer?page=1&>,
'bottle.request.query': <bottle.FormsDict object at 0x405bdd0>,
'bottle.request.urlparts': SplitResult(scheme='http', netloc='127.0.0.1:8888', path='/stream/data/rwer', query='page=1&', fragment=''),
'bottle.route': <GET '/data/<slug>' <function data at 0x3dec9b0>>,
'route.handle': <GET '/data/<slug>' <function data at 0x3dec9b0>>,
'route.url_args': {'slug': 'rwer'},
'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fb8ebafb1e0>,
'wsgi.input': <gevent.pywsgi.Input object at 0x405b050>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0),
'wsgi.websocket': None,
'wsgi.websocket_version': '13'} failed with TypeError
The library works fine when used directly, and also when I use it through nginx. But when I try to run the app with uwsgi, I get None for the websocket (ws) in the handler. I just copied your echo handler for a quick test.
@app.get('/websocket', apply=[websocket], name='ws')
def echo(ws):
while True:
msg = ws.receive()
print('got', msg)
if msg is not None:
ws.send(msg)
print('sent', msg)
else:
break
I'm missing something in the configuration of uwsgi I guess. Do you have an example of running it with uwsgi?
duke@duke-uf /mnt/TT/p2p $ python3.5 ser.py
Bottle v0.12.9 server starting up (using GeventWebSocketServer())...
Listening on http://127.0.0.1:8001/
Hit Ctrl-C to quit.
Traceback (most recent call last):
File "/usr/lib64/python3.5/site-packages/gevent/greenlet.py", line 534, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/lib64/python3.5/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
return handle(*args_tuple)
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 1253, in handle
handler.handle()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 443, in handle
result = self.handle_one_request()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
self.handle_one_response()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
self.log_request()
File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 236, in log_request
if '101' not in self.status:
TypeError: a bytes-like object is required, not 'str'
<Greenlet at 0x7fe9fed65af8: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed] object, fd=-1, )> failed with TypeError
Traceback (most recent call last):
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 884, in handle_one_response
self.run_application()
File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 70, in run_application
self.result = self.upgrade_websocket()
File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 129, in upgrade_websocket
return self.upgrade_connection()
File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 219, in upgrade_connection
hashlib.sha1(key + self.GUID).digest())),
TypeError: Unicode-objects must be encoded before hashing
{'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch',
'HTTP_ACCEPT_LANGUAGE': 'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4',
'HTTP_CACHE_CONTROL': 'no-cache',
'HTTP_CONNECTION': 'Upgrade',
'HTTP_HOST': '127.0.0.1:8001',
'HTTP_ORIGIN': 'http://localhost:8001',
'HTTP_PRAGMA': 'no-cache',
'HTTP_SEC_WEBSOCKET_EXTENSIONS': 'permessage-deflate; client_max_window_bits',
'HTTP_SEC_WEBSOCKET_KEY': 'GqFj9N4XhFEex2uEF7Xs/A==',
'HTTP_SEC_WEBSOCKET_VERSION': '13',
'HTTP_UPGRADE': 'websocket',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36',
'PATH_INFO': '/websocket',
'QUERY_STRING': '',
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_PORT': '38446',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '8001',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'gevent/1.1 Python/3.5',
'wsgi.errors': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>,
'wsgi.input': <gevent.pywsgi.Input object at 0x7fe9fdc51948>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0),
'wsgi.websocket': <geventwebsocket.websocket.WebSocket object at 0x7fe9fd7b1250>,
'wsgi.websocket_version': '13'} failed with TypeError
Traceback (most recent call last):
File "/usr/lib64/python3.5/site-packages/gevent/greenlet.py", line 534, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/lib64/python3.5/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
return handle(*args_tuple)
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 1253, in handle
handler.handle()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 443, in handle
result = self.handle_one_request()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
self.handle_one_response()
File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
self.log_request()
File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 236, in log_request
if '101' not in self.status:
TypeError: a bytes-like object is required, not 'str'
<Greenlet at 0x7fe9fdc55df0: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed] object, fd=-1, )> failed with TypeError
Error on install:
Downloading/unpacking bottle-websocket (from -r requirements.txt (line 7))
Downloading bottle-websocket-0.2.6.tar.gz
Running setup.py (path:/home/travis/virtualenv/python2.7/build/bottle-websocket/setup.py) egg_info for package bottle-websocket
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/travis/virtualenv/python2.7/build/bottle-websocket/setup.py", line 13, in <module>
long_description=open('README.md'),
IOError: [Errno 2] No such file or directory: 'README.md'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/travis/virtualenv/python2.7/build/bottle-websocket/setup.py", line 13, in <module>
long_description=open('README.md'),
IOError: [Errno 2] No such file or directory: 'README.md'
how to use wss later?
Thanks for this module!
Would you have a Hello world example ?
i.e. server code + client code as well (to be displayed in browser)
It appears to be looking for the "Read Me" file, which is not included in the tarball.
# pip2 install bottle-websocket
Downloading/unpacking bottle-websocket
Downloading bottle-websocket-0.2.tar.gz
Running setup.py egg_info for package bottle-websocket
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/bottle-websocket/setup.py", line 10, in <module>
long_description=open('README.md').read(),
IOError: [Errno 2] No such file or directory: 'README.md'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/bottle-websocket/setup.py", line 10, in <module>
long_description=open('README.md').read(),
IOError: [Errno 2] No such file or directory: 'README.md'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/bottle-websocket
hey firend i very like this package
but python3.5 error python2.7 is ok so the package is not work for python3.5 ?
Is it possible to use this to respond to wss:// ?
If yes, I would like to see a configuration example, as I have been unable to figure out something that works.
I'm catching the above error reproducible if a client, which has connected to my GeventWebsockeServer based server, is no longer receiving data, while the server is sending. My websocket server pushes every 100 ms e.g. to a browser app. If I close the lid of PC wich runs the browser client, the a.m. error appears on each send
after 30 seconds. Then, if the remote client is listening again, it recovers after another 30 secs.
Anything I can do better here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.