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

suddenly connects, even though the user is offline (sometimes) #157

Closed
bakteribaik opened this issue Dec 13, 2023 · 3 comments
Closed

suddenly connects, even though the user is offline (sometimes) #157

bakteribaik opened this issue Dec 13, 2023 · 3 comments

Comments

@bakteribaik
Copy link

bakteribaik commented Dec 13, 2023

So I created the TikTok Live Connector as a tool to check whether this username is live or not within a certain period of time. This is what the code looks like

const { WebcastPushConnection } = require('tiktok-live-connector');

let tiktok = new WebCastPushConnection('username');
let connected = false;

setInterval(()=> {
  if(connected === true) return;
  tiktok.connect().then((stats) => console.log(stats.roomId)).catch((err) => console.error(err));
}, 60000);

tiktok.on('StreamEnd', () => {
  if(connected){
      connected = false;
  }
});

Sometimes this code runs very well, but sometimes it also reads that the user is live even though the user is offline. maybe someone has an idea about this?

@ZmoleCristian
Copy link

Same problem here
I cannot find any reliable method to check live true/false

@ZmoleCristian
Copy link

So I created the TikTok Live Connector as a tool to check whether this username is live or not within a certain period of time. This is what the code looks like

const { WebcastPushConnection } = require('tiktok-live-connector');

let tiktok = new WebCastPushConnection('username');
let connected = false;

setInterval(()=> {
  if(connected === true) return;
  tiktok.connect().then((stats) => console.log(stats.roomId)).catch((err) => console.error(err));
}, 60000);

tiktok.on('StreamEnd', () => {
  if(connected){
      connected = false;
  }
});

Sometimes this code runs very well, but sometimes it also reads that the user is live even though the user is offline. maybe someone has an idea about this?

This functionality is implemented in the python version.
https://github.com/isaackogan/TikTokLive?tab=readme-ov-file#checking-if-a-user-is-live

@bakteribaik
Copy link
Author

bakteribaik commented May 23, 2024

i just added a conditional value like this

if(Object.keys(stat.roomInfo).length > 2){
   console.log('user live & send message');
 }

so when the library suddenly connect to room even the user is offline, the roomInfo is empty so we can do like tiktok.disconnect() first and then we try to connect to check the user live or not.

@bakteribaik bakteribaik closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
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

2 participants