[Python] (NODRIVER) Possible Websocket Error or is it Me?

Discussão em 'Python' iniciado por Stack, Abril 2, 2025.

  1. Stack

    Stack Membro Participativo

    Unsure what the issue is but I keep getting this error when I start up my loop. Basically if I run it a certain amount of times, randomly throughout the times, in the beginning, Ill get the error. it doesnt really affect the process, as it still continues. But its a very annoying error message and it floods my logs.

    Error:

    Task exception was never retrieved
    future: <Task finished name='Task-1972' coro=<Connection.aclose() done, defined at C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\nodriver\core\connection.py:305> exception=ConnectionClosedError(None, Close(code=<CloseCode.NORMAL_CLOSURE: 1000>, reason=''), None)>
    Traceback (most recent call last):
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\nodriver\core\connection.py", line 313, in aclose
    await self.websocket.close()
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\protocol.py", line 763, in close
    await self.write_close_frame(Close(code, reason))
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\protocol.py", line 1224, in write_close_frame
    await self.write_frame(True, OP_CLOSE, data, _state=State.CLOSING)
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\protocol.py", line 1199, in write_frame
    await self.drain()
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\protocol.py", line 1188, in drain
    await self.ensure_open()
    File "C:\Users\justv\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\protocol.py", line 929, in ensure_open
    raise self.connection_closed_exc()
    websockets.exceptions.ConnectionClosedError: sent 1000 (OK); no close frame received


    This is a snippet of my code that most likely correlates to the issue. If it doesnt, its most likely an issue with nodriver. Let me know if someone can help!

    async def sign():
    browser_args.append(f"--headless=new")
    browser = await uc.start(browser_args=browser_args)
    main_tab = await browser.get("draft:,")
    try:
    finish = await tab.find("Get Started", best_match=True)
    if finish:
    return email

    except Exception as e:
    print(f"Error: {e}")
    return None
    finally:
    browser.stop()

    return None


    if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.set_exception_handler(exception_handler)

    try:
    asyncio.run(sign())
    except Exception as e:
    print(f"Unhandled exception: {e}")

    Continue reading...

Compartilhe esta Página