Danielhiversen/pyTibber

websockets.exceptions.ConnectionClosedError: received 4500 (private use)

Closed this issue · 13 comments

I constantly getting this ErrorCode:
websockets.exceptions.ConnectionClosedError: received 4500 (private use) Internal server error; then sent 4500 (private use) Internal server error

I´ve checked the Token several times, and in the API-Explorer erverything works fine:-)
Tibber Support can´t help..
THX BastiR

What version of the library are you using?
Could you share the stack trace?

Sorry:-) I use the lateest Version: Here Is the stacktrace.
same for the DEMO Token and one for my personal.

PERSONAL Token:
PS C:\Users\RotheS\Desktop> & C:/Users/RotheS/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/RotheS/Desktop/tibber.py INFO:gql.transport.websockets:>>> {"type": "connection_init", "payload": {}} Traceback (most recent call last): File "c:\Users\RotheS\Desktop\tibber.py", line 61, in <module> asyncio.run(main()) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "c:\Users\RotheS\Desktop\tibber.py", line 30, in main async with Client( File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\client.py", line 658, in __aenter__ return await self.connect_async() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\client.py", line 632, in connect_async await self.transport.connect() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets_base.py", line 514, in connect raise e File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets_base.py", line 512, in connect await self._initialize() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets.py", line 152, in _initialize await self._send_init_message_and_wait_ack() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets.py", line 149, in _send_init_message_and_wait_ack await asyncio.wait_for(self._wait_ack(), self.ack_timeout) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\tasks.py", line 445, in wait_for return fut.result() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets.py", line 124, in _wait_ack init_answer = await self._receive() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gql\transport\websockets_base.py", line 231, in _receive data: Data = await self.websocket.recv() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\websockets\legacy\protocol.py", line 568, in recv await self.ensure_open() File "C:\Users\RotheS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\websockets\legacy\protocol.py", line 953, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedError: received 4500 (private use) Internal server error; then sent 4500 (private use) Internal server error PS C:\Users\RotheS\Desktop>

Hope this will help to find the cause.
THX BastiR

Could you share the python script you use?

`import tibber.const
import asyncio

import aiohttp
import tibber

ACCESS_TOKEN = tibber.const.DEMO_TOKEN

def _callback(pkg):
print(pkg)
data = pkg.get("data")
if data is None:
return
print(data.get("liveMeasurement"))

async def run():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(ACCESS_TOKEN, websession=session, user_agent="change_this")
await tibber_connection.update_info()
home = tibber_connection.get_homes()[0]
await home.rt_subscribe(_callback)

while True:
  await asyncio.sleep(10)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())`

Have you tried with a proper user_agent ?

Where it says user_agent="change_this" in your code

Try with your name or anything else

same error:-(

Sorry, then I do not know. Not able to reproduce it here.

Problem found: Wrong gql-path:
This is the right one:-)
wss://websocket-api.tibber.com/v1-beta/gql/subscriptions