miguelgrinberg / simple-websocket

Simple WebSocket server and client for Python.
MIT License
79 stars 17 forks source link

CloseConnection wrong params #25

Closed NguyenKhong closed 1 year ago

NguyenKhong commented 1 year ago

This a line out_data = self.ws.send(CloseConnection(reason or CloseReason.NORMAL_CLOSURE, message)) in a ws.py file at line 125, throw exception TypeError: init() takes 1 positional argument but 3 were given.

The class CloseConnection only accept *kwargs but pass into args, so it throw a exception. I so hope the author will fix it.

miguelgrinberg commented 1 year ago

I don't think you are correct. I tested this in a Python session:

>>> from wsproto.events import CloseConnection
>>> c = CloseConnection(1000, 'close')
>>> c
CloseConnection(code=1000, reason='close')

What version of wsproto do you have installed in your virtualenv?

NguyenKhong commented 1 year ago

I use wsproto-0.14.1. May be it too old. I update to the last version and it is good working.