sharebook-kr / pybithumb

python wrapper for bithumb API
MIT License
94 stars 55 forks source link

웹소켓 에러 문의드립니다. #41

Open hsh4269 opened 3 months ago

hsh4269 commented 3 months ago

안녕하세요. 파이썬으로 빗썸 웹소켓을 사용하는데 주기적으로 오류가 나타나서 문의드립니다.

오류 메세지는 다음과 같습니다.

Process WebSocketManager-3:1: Traceback (most recent call last): File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 974, in transfer_data message = await self.read_message() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 1044, in read_message frame = await self.read_data_frame(max_size=self.max_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 1119, in read_data_frame frame = await self.read_frame(max_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 1176, in read_frame frame = await Frame.read( ^^^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\framing.py", line 69, in read data = await reader(2) ^^^^^^^^^^^^^^^ asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "c:\Program Files\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\pybithumb\websocket.py", line 71, in run self.aloop.run_until_complete(self.connect_socket()) File "c:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\pybithumb\websocket.py", line 66, in __connect_socket recv_data = await websocket.recv() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 568, in recv await self.ensure_open() File "C:\Users\HSH\AppData\Roaming\Python\Python311\site-packages\websockets\legacy\protocol.py", line 941, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedError: no close frame received or sent

참고로 검색을 통해서 async def __connect_socket(self): uri = "wss://pubwss.bithumb.com/pub/ws"

    async with websockets.connect(uri, ping_interval=60) as websocket:
        connection_msg = await websocket.recv()
        # {"status":"0000","resmsg":"Connected Successfully"}
        if "Connected Successfully" not in connection_msg :
            print("connection error")

        data = {
            "type"     : self.type,
            'symbols'  : self.symbols,
            'tickTypes': self.ticktype
        }
        await websocket.send(json.dumps(data))

        registration_msg = await websocket.recv()
        # {"status":"0000","resmsg":"Filter Registered Successfully"}
        if "Filter Registered Successfully" not in registration_msg:
            print("Registration error")

        while self.alive:
            recv_data = await websocket.recv()
            self.__q.put(json.loads(recv_data))

ping_interval = None 에서 60으로 바꿨습니다. 그래도 동일한 현상이 나타나네요....ㅠㅠ 답변 부탁드리겠습니다.