TikTok-Live-Connector: Uncaught TypeError: Cannot read properties of undefined (reading 'gift_type')
Hello, what can it be? We use a simple code and sometimes it gives this error
Uncaught TypeError: Cannot read properties of undefined (reading ‘gift_type’)
if (data.gift.gift_type === 1 && data.gift.repeat_end === 0) {} else {
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 34 (22 by maintainers)
Commits related to this issue
- Fix WebcastGiftMessage structure #23 — committed to zerodytrash/TikTok-Live-Connector by zerodytrash 2 years ago
I amended the gift proto definition to include the
to_user_id, as one room can have multiple people which receive gifts, see screenshot. Also added the timestamp as I thought that could be of value.https://github.com/Davincible/gotiktoklive/blob/master/proto/tiktok.proto#L46-L60
Also noticed the health disclaimer shown at the bottom of the screenshot is the
WebcastBottomMessagehttps://github.com/Davincible/gotiktoklive/blob/master/proto/tiktok.proto#L245-L248
Will copy this over to the Python port, thanks a million. On another note, if you two are interested, we could set up a chat on some common platform to keep up to date on these things. What do you think?
Isaac
gift_typeis restored via https://github.com/zerodytrash/TikTok-Live-Connector/commit/af2b9cf912bb216dff2d2d29bfd25a194db7e207Gift events now also contain details about the gift like gift name, diamondCount and icon. As a result, the
enableExtendedGiftInfooption is no longer required to determine these values.See https://github.com/zerodytrash/TikTok-Live-Connector#gift
Seems like the
WebcastGiftMessagehas a new structure. I believe it’s like this:The removal of the old JSON structure seems to happen slowly. Maybe they want to test the new format gradually to detect problems early.
The new format also affects the structure of the
giftevent. The attributegiftwith the sub-attributesgift_id,repeat_countandrepeat_endstill exists, but is now deprecated and should no longer be used. The new attributesgiftId,repeatCountandrepeatEndare now on top level. TheextendedGiftInfoattribute exists unchanged (if option enabled). Will update the docs.oh except one
Have connected to the mentioned streamer for ~15 minutes and 148 gifts have been tracked. All containing a parsable json.
Just came here to mention this issue! Going to implement a bandaid fix in my library so it stops causing errors.
Here is an example invalid JSON payload
Here is the base64 message that came from
CrIJChJXZWJjYXN0R2lmdE1lc3NhZ2UQqpaR4MqJoapiGIWWiKix6p6qYiDBx53RgTAwAT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Zjg4ZDcxODkqByNBMzdDOTYSCVNlbnQgUm9zZSDoByiXLDgBUAFYAWABaAGCAQRSb3NlqgGEAgplaHR0cHM6Ly9wMTYtd2ViY2FzdC50aWt0b2tjZG4uY29tL2ltZy9tYWxpdmEvd2ViY2FzdC12YS9lYmEzYTliYjg1YzMzZTAxN2YzNjQ4ZWFmODhkNzE4OX50cGx2LW9iai5wbmcKZWh0dHBzOi8vcDE5LXdlYmNhc3QudGlrdG9rY2RuLmNvbS9pbWcvbWFsaXZhL3dlYmNhc3QtdmEvZWJhM2E5YmI4NWMzM2UwMTdmMzY0OGVhZjg4ZDcxODl+dHBsdi1vYmoucG5nEit3ZWJjYXN0LXZhL2ViYTNhOWJiODVjMzNlMDE3ZjM2NDhlYWY4OGQ3MTg5KgcjQjFDQ0EzggEiMjAyMjA0MTExOTQzNTAwMTAxMTMxMzUxMjgwMEZDNTJBOIgBBJoBALoBMwiFiKX65Nyci2EYkMOd0YEwIMvFndGBMCiRwJ3RgTAwwced0YEwOP8CQIWIpfrk3JyLYQ==@Davincible Gifts with
gift_type:1are streakable.repeat_endon these gifts means the streak ended and the event is just a summary of the final state (including the finalrepeat_count. Thats already described here: https://github.com/zerodytrash/TikTok-Live-Connector#gift@OlegShklyarov This is an issue with socket.io and not with this library. Maybe your server configuration is incorrect. You can find the documentation for socket.io here. Next days I will improve the reconnect logic of the TikTok-Chat-Reader to restore the connection even if the socket.io connection drops.
Hint: If you use a reverse proxy like Nginx on your server, then you have to change the configuration to make websocket connections work for socket.io. Otherwise socket.io uses a fallback to long polling, which can cause the described error. More info: https://socket.io/docs/v4/reverse-proxy/