Closed nitanmarcel closed 3 years ago
auto reconnect works for GroupCallFile. There is need more info about your case with GroupCallRaw
auto reconnect works for GroupCallFile. There is need more info about your case with GroupCallRaw
I'll do some tests when I get home. Maybe something happens when the library reads the raw bytes and a disconnection happens.
Here's a small example on how I prepare the data from reading. The stream comes from a ffmpeg subprocess with the output redirected to stdout instead to a file.
def get_chunk(self, _, length: int) -> Optional[bytes]:
if self._process:
data = self._process.stdout.read(length)
It doesn't happen only on reconnect, it probably has something to do on how the bytes are parsed in the c++ library or I don't know. I have no idea how to debug it honestly
I tried multiple ways to replicate the error:
@MarshalX I did some tests and it looks that free(): invalid pointer
also happens on group_call.stop()
.
Code to reproduce the error:
async def main(client):
async with client:
group_call_factory = GroupCallFactory(client, CLIENT_TYPE)
group_call = group_call_factory.get_raw_group_call(on_played_data=on_played_data)
await group_call.start(PEER)
await asyncio.sleep(5)
await group_call.stop()
# Exits with free(): invalid pointer
Logs:
DEBUG:asyncio:Using selector: EpollSelector
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.91:443/TcpFull...
INFO:telethon.network.mtprotosender:Connection to 149.154.167.91:443/TcpFull complete!
DEBUG:pytgcalls.dispatcher.dispatcher:Build storage of handlers for dispatcher.
DEBUG:pytgcalls.implementation.group_call_native:Create a new native instance..
DEBUG:pytgcalls.implementation.group_call_native:Native instance created.
DEBUG:pytgcalls.implementation.group_call_native:Start native group call..
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7fc2e62ef9a0>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62fc520>})]})
DEBUG:pytgcalls.implementation.group_call_native:Not equal ssrc. Expected: 253702336. Actual: None
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=253702336 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62ef970>})]})
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7fc2e62ef0a0>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62fc3a0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=253702336 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62ef310>})]})
DEBUG:pytgcalls.implementation.group_call_native:Network state updated..
DEBUG:pytgcalls.implementation.group_call_native:Set is muted. New value: False.
DEBUG:pytgcalls.dispatcher.dispatcher:Trigger handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.dispatcher.dispatcher:Get handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.implementation.group_call_native:New network state is True.
DEBUG:pytgcalls.implementation.group_call_native:Start status (call action) worker..
DEBUG:pytgcalls.implementation.group_call_native:Stop requested.
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
DEBUG:asyncio:Using selector: EpollSelector
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.91:443/TcpFull...
INFO:telethon.network.mtprotosender:Connection to 149.154.167.91:443/TcpFull complete!
DEBUG:pytgcalls.dispatcher.dispatcher:Build storage of handlers for dispatcher.
DEBUG:pytgcalls.implementation.group_call_native:Create a new native instance..
DEBUG:pytgcalls.implementation.group_call_native:Native instance created.
DEBUG:pytgcalls.implementation.group_call_native:Start native group call..
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7fc2e62ef9a0>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62fc520>})]})
DEBUG:pytgcalls.implementation.group_call_native:Not equal ssrc. Expected: 253702336. Actual: None
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=253702336 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62ef970>})]})
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7fc2e62ef0a0>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62fc3a0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=253702336 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 253702336, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7fc2e62ef310>})]})
DEBUG:pytgcalls.implementation.group_call_native:Network state updated..
DEBUG:pytgcalls.implementation.group_call_native:Set is muted. New value: False.
DEBUG:pytgcalls.dispatcher.dispatcher:Trigger handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.dispatcher.dispatcher:Get handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.implementation.group_call_native:New network state is True.
DEBUG:pytgcalls.implementation.group_call_native:Start status (call action) worker..
DEBUG:pytgcalls.implementation.group_call_native:Stop requested.
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
This also happens when calling group_call.start()
after calling group_call.leave_current_group_call()
Code to reproduce the error:
async def main(client):
async with client:
group_call_factory = GroupCallFactory(client, CLIENT_TYPE)
group_call = group_call_factory.get_raw_group_call(on_played_data=on_played_data)
await group_call.start(PEER)
await asyncio.sleep(5)
await group_call.leave_current_group_call()
await asyncio.sleep(5)
await group_call.reconnect()
# Exits with free(): invalid pointer
Logs:
DEBUG:asyncio:Using selector: EpollSelector
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.91:443/TcpFull...
INFO:telethon.network.mtprotosender:Connection to 149.154.167.91:443/TcpFull complete!
DEBUG:pytgcalls.dispatcher.dispatcher:Build storage of handlers for dispatcher.
DEBUG:pytgcalls.implementation.group_call_native:Create a new native instance..
DEBUG:pytgcalls.implementation.group_call_native:Native instance created.
DEBUG:pytgcalls.implementation.group_call_native:Start native group call..
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7f80fc3e5730>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc374bb0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Not equal ssrc. Expected: 291289022. Actual: None
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=291289022 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc3e5610>})]})
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7f80fc3e5610>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc37cc10>})]})
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=291289022 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc3e5d90>})]})
DEBUG:pytgcalls.implementation.group_call_native:Network state updated..
DEBUG:pytgcalls.implementation.group_call_native:Set is muted. New value: False.
DEBUG:pytgcalls.dispatcher.dispatcher:Trigger handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.dispatcher.dispatcher:Get handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.implementation.group_call_native:New network state is True.
DEBUG:pytgcalls.implementation.group_call_native:Start status (call action) worker..
DEBUG:pytgcalls.implementation.group_call_native:Try to leave current group call.
DEBUG:pytgcalls.implementation.group_call_native:Completely leave current group call.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': True, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc374bb0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Remove ssrcs [291289022].
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 291289022, 'left': True, 'peer': <telethon.tl.types.PeerUser object at 0x7f80fc374eb0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Remove ssrcs [291289022].
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
I even tried calling group_call.reconnect()
:
Code to reproduce the error:
async def main(client):
async with client:
group_call_factory = GroupCallFactory(client, CLIENT_TYPE)
group_call = group_call_factory.get_raw_group_call(on_played_data=on_played_data)
await group_call.start(PEER)
await asyncio.sleep(5)
await group_call.leave_current_group_call()
await asyncio.sleep(5)
await group_call.reconnect()
# Exits with free(): invalid pointer
Logs:
DEBUG:asyncio:Using selector: EpollSelector
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.91:443/TcpFull...
INFO:telethon.network.mtprotosender:Connection to 149.154.167.91:443/TcpFull complete!
DEBUG:pytgcalls.dispatcher.dispatcher:Build storage of handlers for dispatcher.
DEBUG:pytgcalls.implementation.group_call_native:Create a new native instance..
DEBUG:pytgcalls.implementation.group_call_native:Native instance created.
DEBUG:pytgcalls.implementation.group_call_native:Start native group call..
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7f93b4130730>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b413e460>})]})
DEBUG:pytgcalls.implementation.group_call_native:Not equal ssrc. Expected: 762352162. Actual: None
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
DEBUG:pytgcalls.implementation.group_call_native:Emit join payload..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=762352162 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b4130880>})]})
DEBUG:pytgcalls.implementation.group_call_native:Group call update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallWrapper>({'chat_id': 'placeholder', 'call': <GroupCallWrapper>({'id': 'placeholder', 'params': <telethon.tl.types.DataJSON object at 0x7f93b4130880>})})
DEBUG:pytgcalls.implementation.group_call_native:Set join response payload..
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b40c90d0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeRtc
DEBUG:pytgcalls.implementation.group_call_native:Join response payload was set.
DEBUG:pytgcalls.implementation.group_call_native:Successfully connected to VC with ssrc=762352162 as PeerUser.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': False, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b4130e20>})]})
DEBUG:pytgcalls.implementation.group_call_native:Network state updated..
DEBUG:pytgcalls.implementation.group_call_native:Set is muted. New value: False.
DEBUG:pytgcalls.dispatcher.dispatcher:Trigger handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.dispatcher.dispatcher:Get handlers of NETWORK_STATUS_CHANGED
DEBUG:pytgcalls.implementation.group_call_native:New network state is True.
DEBUG:pytgcalls.implementation.group_call_native:Start status (call action) worker..
DEBUG:pytgcalls.implementation.group_call_native:Try to leave current group call.
DEBUG:pytgcalls.implementation.group_call_native:Completely leave current group call.
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': True, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b413e4f0>})]})
DEBUG:pytgcalls.implementation.group_call_native:Remove ssrcs [762352162].
DEBUG:pytgcalls.implementation.group_call_native:Group call participants update..
DEBUG:pytgcalls.implementation.group_call_native:<UpdateGroupCallParticipantsWrapper>({'participants': [<GroupCallParticipantWrapper>({'source': 762352162, 'left': True, 'peer': <telethon.tl.types.PeerUser object at 0x7f93b413e040>})]})
DEBUG:pytgcalls.implementation.group_call_native:Remove ssrcs [762352162].
DEBUG:pytgcalls.implementation.group_call_native:Reconnecting..
DEBUG:pytgcalls.implementation.group_call_native:Set connection mode GroupConnectionMode.GroupConnectionModeNone
If both group_call.stop_playout()
and group_call.stop_output()
are called before calling group_call.stop()
the client is able to reconnect without any problems.
So, by mistake I forgot to switch accounts so I tried joining with the same account as I was streaming and the app crashed for me with
free(): invalid pointer
.I know you can't join an account if is already joined but probably the error should be handled to not interrupt the workflow.
Debug Logs: