Closed you-ri closed 2 years ago
Stop passing session id data on headers, this is most likely what is causing your issue. It is not required anymore and I believe TikTok have gone as far as banning accounts that use them with this library.
Isaac
I have the same problem. Is this library no longer available?
Hello, please read my above comment. As far as I am aware the library is working just fine, or I'd have received far more complaints. Update the library and/or post your code.
Thank you for your answer.
I just installed 4.3.3 version
of TicTokLive
and ran basic.py
.
from TikTokLive import TikTokLiveClient
from TikTokLive.types.events import CommentEvent, ConnectEvent
# Instantiate the client with the user's username
client: TikTokLiveClient = TikTokLiveClient(unique_id="koo0_90")
# Define how you want to handle specific events via decorator
@client.on("connect")
async def on_connect(_: ConnectEvent):
print("Connected to Room ID:", client.room_id)
# Notice no decorator?
async def on_comment(event: CommentEvent):
print(f"{event.user.nickname} -> {event.comment}")
# Define handling an event via "callback"
client.add_listener("comment", on_comment)
if __name__ == '__main__':
# Run the client and block the main thread
# await client.start() to run non-blocking
client.run()
C:\Users\Hong\Desktop\serverSet\tictok>python basic.py
Traceback (most recent call last):
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 380, in _connect
await self.__fetch_room_data(True)
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 221, in __fetch_room_data
raise InitialCursorMissing("Missing cursor in initial fetch response.")
TikTokLive.types.errors.InitialCursorMissing: Missing cursor in initial fetch response.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Hong\Desktop\serverSet\tictok\basic.py", line 25, in <module>
client.run()
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 461, in run
self.loop.run_until_complete(self._connect(session_id=session_id))
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 86, in _connect
result: str = await super(TikTokLiveClient, self)._connect(session_id=session_id)
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 412, in _connect
await self._on_error(ex, FailedConnection(message))
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 54, in _on_error
raise _exc
File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 48, in _on_error
raise append from original
TikTokLive.types.errors.FailedConnection: Missing cursor in initial fetch response.
Is there something I am missing?
You need the @ before your user id like the example. TikTokLiveClient = TikTokLiveClient(unique_id="@isaackogz")
TikTokLiveClient(unique_id="@koo0_90")
Actually the @ shouldn't matter. Maybe there's an issue. Try with the @, but I'll do more looking when I get home tomorrow.
I know I had this same issue on a previous version when I left the @ off and adding it fixed it. Haven't tried it without @ on 4.3.3. I'm also not home for a day otherwise I'd verify it.
I've already tried adding @, but it still causes the same problem.
Ah OK. I may be confused with another error I had previously.
You should check that you aren't trying to connect to more than 2 clients at once.
Thank you for your answer. I just installed of and ran .
4.3.3 version``TicTokLive``basic.py
from TikTokLive import TikTokLiveClient from TikTokLive.types.events import CommentEvent, ConnectEvent # Instantiate the client with the user's username client: TikTokLiveClient = TikTokLiveClient(unique_id="koo0_90") # Define how you want to handle specific events via decorator @client.on("connect") async def on_connect(_: ConnectEvent): print("Connected to Room ID:", client.room_id) # Notice no decorator? async def on_comment(event: CommentEvent): print(f"{event.user.nickname} -> {event.comment}") # Define handling an event via "callback" client.add_listener("comment", on_comment) if __name__ == '__main__': # Run the client and block the main thread # await client.start() to run non-blocking client.run()
C:\Users\Hong\Desktop\serverSet\tictok>python basic.py Traceback (most recent call last): File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 380, in _connect await self.__fetch_room_data(True) File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 221, in __fetch_room_data raise InitialCursorMissing("Missing cursor in initial fetch response.") TikTokLive.types.errors.InitialCursorMissing: Missing cursor in initial fetch response. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\Hong\Desktop\serverSet\tictok\basic.py", line 25, in <module> client.run() File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 461, in run self.loop.run_until_complete(self._connect(session_id=session_id)) File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 86, in _connect result: str = await super(TikTokLiveClient, self)._connect(session_id=session_id) File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\base.py", line 412, in _connect await self._on_error(ex, FailedConnection(message)) File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 54, in _on_error raise _exc File "C:\Users\Hong\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokLive\client\client.py", line 48, in _on_error raise append from original TikTokLive.types.errors.FailedConnection: Missing cursor in initial fetch response.
Is there something I am missing?
I have the same problem. What should I do?
Your IP is blocked, it looks like. From my end, everything works. Try using a VPN to connect to the USA and see if that makes a difference.
In v4.3.3, running
basic.py
in exsample or simple code such as the following now causes an error.When I bring it down to v4.2.0, the error no longer occurs but it is not responsive. Two weeks ago it was working fine. Is there something I am missing?