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

TikTokLive.client.errors.WebcastBlocked200Error: WebSocket rejected by TikTok with a 200 status code, implying detection. #280

Open
ruolunhui opened this issue Dec 26, 2024 · 2 comments

Comments

@ruolunhui
Copy link

ruolunhui commented Dec 26, 2024

TikTokLive==6.3.0.post2

from TikTokLive.client.web.web_settings import WebDefaults
WebDefaults.tiktok_sign_api_key = 'ZWY2YTQ...'
from TikTokLive.client.client import TikTokLiveClient
from TikTokLive.client.logger import LogLevel
from TikTokLive.events import ConnectEvent
room_id = '@aekoshoes'
client: TikTokLiveClient = TikTokLiveClient(unique_id=room_id)
client.web.set_session_id("87ac8c3a795809b888f068a484813ab9")

@client.on(ConnectEvent)
async def on_connect(event: ConnectEvent):
await send_messag_test();
client.logger.info(f"Connected to @{event.unique_id}!")

async def send_messag_test():
extra_params: dict = {"content": "Hello world!"}

  if room_id is not None:
      extra_params["room_id"] = room_id
  client.web.set_session_id("87ac8c3a795809b888f068a484813ab9")
  responseSrc = await client.web.send_room_chat("Hello world!")
  responseSrc = await  client.web.send_room_chat("Hello world Test!")

if name == 'main':
client.logger.setLevel(LogLevel.INFO.value)
client.run()

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

Traceback (most recent call last):
File "/usr/local/serve/audio_chat_project/test/logged_in.py", line 97, in
client.run()
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/site-packages/TikTokLive/client/client.py", line 212, in run
return self._asyncio_loop.run_until_complete(self.connect(**kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/site-packages/TikTokLive/client/client.py", line 197, in connect
await task
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/site-packages/TikTokLive/client/client.py", line 308, in _ws_client_loop
async for webcast_response in self._ws.connect(
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/site-packages/TikTokLive/client/ws/ws_client.py", line 220, in connect
async for webcast_push_frame, webcast_response in typing.cast(WebcastIterator, self._connection_generator):
File "/root/anaconda3/envs/test_audio_chat/lib/python3.11/site-packages/TikTokLive/client/ws/ws_connect.py", line 99, in aiter
raise WebcastBlocked200Error("WebSocket rejected by TikTok with a 200 status code, implying detection.") from ex
TikTokLive.client.errors.WebcastBlocked200Error: WebSocket rejected by TikTok with a 200 status code, implying detection.

@isaackogan
Copy link
Owner

Not enough information here

@drehtisch
Copy link

@isaackogan I think i can provide some more information, because i'm seeing this error regularly.

I'm printing the control events to the console. It appears that it always occur at the end of a live.

Log:
Control event STREAM_ENDED
An unexpected error occured: WebSocket rejected by TikTok with a 200 status code, implying detection.
Task exception was never retrieved
future: <Task finished name='Task-93' coro=<TikTokLiveClient.disconnect() done, defined at /home/christoph/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/TikTokLive/client/client.py:214> exception=WebcastBlocked200Error('WebSocket rejected by TikTok with a 200 status code, implying detection.')>
Traceback (most recent call last):
File "/home/{user}/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/TikTokLive/client/ws/ws_connect.py", line 73, in aiter
async with self as protocol:
File "/home/{user}/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/websockets/legacy/client.py", line 632, in aenter
return await self
File "/home/{user}/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/websockets/legacy/client.py", line 653, in await_impl
await protocol.handshake(
File "/home/{user}/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/websockets/legacy/client.py", line 317, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.legacy.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 200

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

Traceback (most recent call last):
File "/home/{user}/anaconda3/envs/tiktoklive/lib/python3.10/site-packages/TikTokLive/client/client.py", line 228, in disconnect
await self._event_loop_task
TikTokLive.client.errors.WebcastBlocked200Error: WebSocket rejected by TikTok with a 200 status code, implying detection.

I also attach my script: live_notify.txt

Trying to suppress the error in my handle_liveend() does not work at it occurs in the check_loop method.
Do i do something wrong or is this an error with tiktoklive? If you have any advice or need more information, let me know.

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

No branches or pull requests

3 participants