sanic icon indicating copy to clipboard operation
sanic copied to clipboard

websockets: unexpected keyword connections

Open benjiqq opened this issue 1 week ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

websockets: unexpected keyword connections

debug log

/root/.cache/pypoetry/virtualenvs/webserver-Mns4wmqm-py3.12/lib/python3.12/site-packages/sanic/touchup/schemes/ode.py:70: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
  if hasattr(event, "s"):
[2024-06-28 08:36:47 +0000] [49052] [INFO] Starting worker [49052]
Unhandled exception in event loop
Traceback (most recent call last):
  File "uvloop/handles/streamserver.pyx", line 148, in uvloop.loop.__uv_streamserver_on_listen
  File "uvloop/handles/streamserver.pyx", line 69, in uvloop.loop.UVStreamServer._on_listen
  File "uvloop/loop.pyx", line 101, in uvloop.loop.run_in_context
TypeError: WebsocketImplProtocol.__init__() got an unexpected keyword argument 'connections'

code

from sanic import Sanic, response
from sanic.response import json, file
from sanic import Request, Websocket
from datetime import datetime
import json  # Ensure you import json
import asyncio

app = Sanic("webserver")

@app.websocket("/feed")
async def feed(request: Request, ws: Websocket):
    while True:
        data = "hello!"
        print("Sending: " + data)
        await ws.send(data)
        data = await ws.recv()
        print("Received: " + data)


if __name__ == "__main__":
    webport = 9000
    print(f"Starting app on port {webport}")
    app.run(host="0.0.0.0", port=int(webport), protocol=Websocket)

versions


 poetry show sanic
 name         : sanic                                                                           
 version      : 23.12.1                                                                        
...
uvloop
 name         : uvloop                                                    
 version      : 0.19.0                                                    

Code snippet

No response

Expected Behavior

No response

How do you run Sanic?

As a module

Operating System

Linux

Sanic Version

23.12.1

Additional context

No response

benjiqq avatar Jun 28 '24 08:06 benjiqq