TikTok-Live-Connector icon indicating copy to clipboard operation
TikTok-Live-Connector copied to clipboard

Duplicate chat events

Open therebelrobot opened this issue 2 years ago • 14 comments

Hi there! Great work on this, it was a lifesaver for me.

One issue I'm running into: when chat events come through, if there isn't immediate other chat messages to push it offscreen, those same chat events run again when it looks for more events (e.g. user 1 comments "hi" once, but the on("chat"... with that data comes through multiple times. I figured one way to filter it out was to grab the timestamp of the chat message and just make sure I keep a log of previously seen messages, but I can't seem to figure out where to find that kind of stamp info. Is there a way I could modify the lib myself locally to add that data? I tried adding msgId or timestamp to the proto for WebcastChatMessage but neither of those seem to have any affect on the results returned.

therebelrobot avatar Mar 14 '22 20:03 therebelrobot

hi, this is a strange behavior. Have not experienced this problem before. Can you check if a websocket connection is used? You can see this in the promise result of the connect() function. Property: upgradedToWebsocket

zerodytrash avatar Mar 14 '22 21:03 zerodytrash

Hello, I have encountered such a problem, may I ask if there is any way to fix it?

asdfg314284230 avatar Mar 20 '22 18:03 asdfg314284230

The error did not occur in my case. If someone can reproduce the problem, feel free to fix it.

zerodytrash avatar Mar 22 '22 01:03 zerodytrash

This may be related to my use of the system agent caused by repeated monitoring, SO far I have not been able to find the cause.

asdfg314284230 avatar Mar 22 '22 01:03 asdfg314284230

Or 3 or 8 repeat chat events can occur when the number of channels monitored is small.

asdfg314284230 avatar Mar 22 '22 01:03 asdfg314284230

May I ask here? How to emit roomInfo from connectionWrapper?

	this.connection.getRoomInfo().then(roomInfo => {
		this.log(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		this.emit(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		})

Is this correct?

OlegShklyarov avatar Apr 18 '22 01:04 OlegShklyarov

The error did not occur in my case. If someone can reproduce the problem, feel free to fix it.

Yes, there is such a problem. It occurs in chats with a small number of participants. I figured out how it happens. The query periodically returns cursor = 0, which causes the chat messages to be requested from the beginning.

I wrote a C# library similar to this one. In my implementation, I simply check that the new cursor is not equal to 0. If it is, then I ignore the query result and make a new one with the previous cursor.

pixorama avatar Apr 18 '22 07:04 pixorama

The error did not occur in my case. If someone can reproduce the problem, feel free to fix it.

Yes, there is such a problem. It occurs in chats with a small number of participants. I figured out how it happens. The query periodically returns cursor = 0, which causes the chat messages to be requested from the beginning.

I wrote a C# library similar to this one. In my implementation, I simply check that the new cursor is not equal to 0. If it is, then I ignore the query result and make a new one with the previous cursor.

The null cursor fix is already implemented: https://github.com/zerodytrash/TikTok-Live-Connector/blob/63129d353032b67636600e753393195f355e5c3a/src/index.js#L339-L341

Let me know if the problem persists.

zerodytrash avatar Apr 18 '22 14:04 zerodytrash

May I ask here? How to emit roomInfo from connectionWrapper?

	this.connection.getRoomInfo().then(roomInfo => {
		this.log(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		this.emit(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		})

Is this correct?

Not sure what you want to do with the code. Please create a new issue since this has nothing to do with this issue.

zerodytrash avatar Apr 18 '22 14:04 zerodytrash

I have solved this problem. It seems to have some influence on the Network in China. Every time it is reconnected, it will be re-issued.  thank you   ------------------ 原始邮件 ------------------ 发件人: "zerodytrash/TikTok-Live-Connector" @.>; 发送时间: 2022年4月18日(星期一) 晚上10:09 @.>; @.@.>; 主题: Re: [zerodytrash/TikTok-Live-Connector] Duplicate chat events (Issue #17)

May I ask here? How to emit roomInfo from connectionWrapper? this.connection.getRoomInfo().then(roomInfo => { this.log(HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}); this.emit(HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}); })
Is this correct?

Not sure what you want to do with the code. Please create a new issue since this has nothing to do with this issue.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

asdfg314284230 avatar Apr 18 '22 14:04 asdfg314284230

Thank you for your answer. The problems I have tested are more about the network environment in China.  

------------------ 原始邮件 ------------------ 发件人: "zerodytrash/TikTok-Live-Connector" @.>; 发送时间: 2022年4月18日(星期一) 晚上10:06 @.>; @.@.>; 主题: Re: [zerodytrash/TikTok-Live-Connector] Duplicate chat events (Issue #17)

The error did not occur in my case. If someone can reproduce the problem, feel free to fix it.

Yes, there is such a problem. It occurs in chats with a small number of participants. I figured out how it happens. The query periodically returns cursor = 0, which causes the chat messages to be requested from the beginning.

I wrote a C# library similar to this one. In my implementation, I simply check that the new cursor is not equal to 0. If it is, then I ignore the query result and make a new one with the previous cursor.

The null cursor fix is already implemented: https://github.com/zerodytrash/TikTok-Live-Connector/blob/63129d353032b67636600e753393195f355e5c3a/src/index.js#L339

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

asdfg314284230 avatar Apr 18 '22 14:04 asdfg314284230

I'm also working on the gift question. Find the email reply to you

------------------ 原始邮件 ------------------ 发件人: "zerodytrash/TikTok-Live-Connector" @.>; 发送时间: 2022年4月18日(星期一) 晚上10:09 @.>; @.@.>; 主题: Re: [zerodytrash/TikTok-Live-Connector] Duplicate chat events (Issue #17)

May I ask here? How to emit roomInfo from connectionWrapper? this.connection.getRoomInfo().then(roomInfo => { this.log(HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}); this.emit(HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}); })
Is this correct?

Not sure what you want to do with the code. Please create a new issue since this has nothing to do with this issue.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

asdfg314284230 avatar Apr 18 '22 14:04 asdfg314284230

@zerodytrash If you look at the proto contents of chat events there are a various types of IDs, I think you can use one of them to identify messages uniquely. I've looked at it briefly but not in-depth

Davincible avatar May 25 '22 14:05 Davincible

@zerodytrash If you look at there proto contents of chat events there are a various types of IDs, I think you can use one of them to identify messages uniquely. I've looked at it briefly but no in-depth

good point. does anyone still have problems with duplicate events?

zerodytrash avatar May 25 '22 14:05 zerodytrash

Hello, I ran into a problem with duplicate gift event

METAIRONY avatar Aug 15 '22 12:08 METAIRONY

Hello, I ran into a problem with duplicate gift event

make sure you handle gift streaks correctly https://github.com/zerodytrash/TikTok-Live-Connector#gift

zerodytrash avatar Aug 16 '22 12:08 zerodytrash

There is a new event attribute msgId in the latest version which can be used to detect duplicates.

zerodytrash avatar Aug 20 '22 14:08 zerodytrash

I also encountered the problem of repeated gift messages today, and both msgId and createTime are not repeated

artwl avatar Sep 22 '22 04:09 artwl