Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime example broken? #283

Closed
mariosk8s opened this issue Dec 5, 2023 · 2 comments · Fixed by #287
Closed

Realtime example broken? #283

mariosk8s opened this issue Dec 5, 2023 · 2 comments · Fixed by #287

Comments

@mariosk8s
Copy link

I'm trying to run the real time example on Debian 11 with Python 3.9 and keep getting a 404

/usr/bin/python3.9 /nas/projects/electronic/mybus/tibber/tibtest.py
Traceback (most recent call last):
File "/nas/projects/electronic/mybus/tibber/tibtest.py", line 33, in
loop.run_until_complete(run())
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/nas/projects/electronic/mybus/tibber/tibtest.py", line 27, in run
await home.rt_subscribe(_callback)
File "/usr/local/lib/python3.9/dist-packages/tibber/tibber_home.py", line 448, in rt_subscribe
await self._tibber_control.rt_connect()
File "/usr/local/lib/python3.9/dist-packages/tibber/init.py", line 110, in rt_connect
await self.sub_manager.connect_async()
File "/usr/local/lib/python3.9/dist-packages/gql/client.py", line 632, in connect_async
await self.transport.connect()
File "/usr/local/lib/python3.9/dist-packages/gql/transport/websockets_base.py", line 490, in connect
self.websocket = await asyncio.wait_for(
File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
return fut.result()
File "/usr/lib/python3.9/asyncio/tasks.py", line 690, in _wrap_awaitable
return (yield from awaitable.await())
File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/client.py", line 659, in await_impl_timeout
return await asyncio.wait_for(self.await_impl(), self.open_timeout)
File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
return fut.result()
File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/client.py", line 666, in await_impl
await protocol.handshake(
File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/client.py", line 332, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

Process finished with exit code 1

It doesn't matter whether i use my own access token or the demo one.
This happens on 26.13 and also on main 28.2 with the following patch to make it jibe on python 3.9

`diff --git a/tibber/realtime.py b/tibber/realtime.py
index 5da2ea3..d6070ad 100644
--- a/tibber/realtime.py
+++ b/tibber/realtime.py
@@ -196,7 +196,7 @@ class TibberRT:
)

 @property
  • def sub_endpoint(self) -> str | None:
  • def sub_endpoint(self) -> Union[str, None]:
    """Get subscription endpoint."""
    return self._sub_endpoint
    `

I would try to debug this myself, but am getting utterly lost in the async world.

@staalebk
Copy link

staalebk commented Dec 8, 2023

The URL in init is wrong. It should be wss://websocket-api.tibber.com/v1-beta/gql/subscriptions
(or rather, it should be acquired by asking for websocketSubscriptionUrl.

@mariosk8s
Copy link
Author

Yes, i neglected to mention it, but i adjusted the URL in 28.2 to no avail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants