xmonader / pygundb

python gundb server and client implementation
68 stars 15 forks source link

websockets.exceptions.ConnectionClosedError #27

Open bitnom opened 5 years ago

bitnom commented 5 years ago

Here's the test code:

import asyncio
from pygundb.client import GunClient
from pygundb.gundb.backends import *

async def test():
    import sys
    argv = sys.argv
    backend = DummyKV()
    if "dummy" in argv:
        backend = DummyKV()
    elif "memory" in argv:
        backend = Memory()
    elif "redis" in argv:
        backend = RedisKV()
    elif "udb" in argv:
        backend = UDB()
    elif "pickle" in argv:
        backend = Pickle()

    c = GunClient()
    c.backend = backend
    print(c.backend.db)
    await c.put('box', w=101, h=30)
    box = await c.get('box')
    print("Box is: ", box)
    w = await c.get('box', 'w')
    print("W is : ", w)
    print(c.backend.db)

def cltest():
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test())

if __name__ == "__main__":
    cltest()

Which results in:

defaultdict(<function Memory.__init__.<locals>.<lambda> at 0x7fb1571ca170>, {})
Traceback (most recent call last):
  File "gun.py", line 38, in <module>
    cltest()
  File "gun.py", line 34, in cltest
    loop.run_until_complete(test())
  File "/home/tensortom/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "gun.py", line 24, in test
    await c.put('box', w=101, h=30)
  File "/home/tensortom/Projects/Hashtagger/pygundb/client.py", line 39, in put
    resp = await ws.recv()
  File "/home/tensortom/.local/share/virtualenvs/Hashtagger-OP1ochSq/lib/python3.7/site-packages/websockets/protocol.py", line 484, in recv
    await self.ensure_open()
  File "/home/tensortom/.local/share/virtualenvs/Hashtagger-OP1ochSq/lib/python3.7/site-packages/websockets/protocol.py", line 780, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1005 (no status code [internal]), no reason
xmonader commented 5 years ago

can you please try again? I added a small client that dispatches (get/put) requests https://github.com/xmonader/pygundb/commit/49790d968fabe7180808c5676fecb7688c096e34

example

bitnom commented 5 years ago

Finally had some time. Same error.

quadrismegistus commented 4 years ago

I also have this error. Any updates on this? Thanks!

rei-gun commented 3 years ago

I've got the same error. On the GunDB side there's this error:


  File "/usr/local/lib/python3.8/site-packages/gevent/pywsgi.py", line 976, in handle_one_response
    self.run_application()
  File "/usr/local/lib/python3.8/site-packages/geventwebsocket/handler.py", line 75, in run_application
    self.run_websocket()
  File "/usr/local/lib/python3.8/site-packages/geventwebsocket/handler.py", line 52, in run_websocket
    list(self.application(self.environ, lambda s, h, e=None: []))
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/flask_sockets.py", line 40, in __call__
    handler, values = adapter.match()
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 2030, in match
    raise WebsocketMismatch()
werkzeug.routing.WebsocketMismatch: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
2021-08-12T14:24:51Z {'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '55996', 'HTTP_HOST': 'localhost:8000', (hidden keys: 26)} failed with WebsocketMismatch```
sevenrats commented 1 year ago

pip3 install --upgrade "flask<2.0"