Commit graph

186 commits

Author SHA1 Message Date
wulan17
375e97d963
Reapply "fix: handle connection closure and retry logic in session management"
This reverts commit 2c3fb1caa6.

Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-07 21:01:42 +07:00
KurimuzonAkuma
1a4c578380
Refactor loop
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-07 21:01:41 +07:00
Hitalo M.
b8028541c9
fix(session): prevent task cancellation race condition in stop method
The fix properly cancels the recv_task and suppresses CancelledError when awaiting
it during session shutdown. This resolves the "read() called while another
coroutine is already waiting for incoming data" RuntimeError that occurred when
stopping sessions during reconnection attempts.

Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-07 20:52:34 +07:00
Hitalo M.
01e7717e52
refactor(session): replace recursion with loop and add backoff
This refactor replaces recursion with a loop in the session invoke logic. Additionally, a backoff mechanism has been introduced to prevent frequent restarts from crashing the bot.

Signed-off-by: wulan17 <wulan17@komodos.id>
2025-06-07 19:59:42 +07:00
wulan17
2c3fb1caa6
Revert "fix: handle connection closure and retry logic in session management"
This reverts commit 4df4478a80.

Signed-off-by: wulan17 <wulan17@komodos.id>
2025-05-18 19:57:20 +07:00
Hitalo M.
4df4478a80
fix: handle connection closure and retry logic in session management
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-05-14 20:48:30 +07:00
wulan17
3e24f006e0
pyrofork: Cleanup codes
Signed-off-by: wulan17 <wulan17@komodos.id>
2025-03-29 00:25:16 +07:00
KurimuzonAkuma
01e200e8ce
Restart client after receiving unknown constructor
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-09-07 20:52:11 +07:00
KurimuzonAkuma
f37c5c9f2f
Change Exception to Unauthorized when auth key not found
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-07-13 15:28:34 +07:00
KurimuzonAkuma
58f0031ead
Raise exception if auth key not found
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-07-13 15:28:34 +07:00
Artem Ukolov
bb4ea00d4e
Implement non-blocking TCP connection (KurimuzonAkuma/pyrogram#71)
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-06-23 16:59:32 +07:00
shriMADhav U k
e414aa2812
pyrofork: Handle FLOOD_PREMIUM_WAIT
Squashed commit of the following:

commit 546b603
commit 0ac858d
commit c8a9725

Ref: https://t.me/swiftgram/72
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-06-02 14:34:47 +07:00
omg-xtao
3f34c96175
Fix ConnectionResetError when only ping task
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-03-23 18:54:51 +07:00
wulan17
1b3f0933c7
Pyrofork: Update Copyright headers
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2024-02-07 20:25:08 +07:00
wulan17
5bb4d936cc
PyroFork: set STORED_MSG_IDS_MAX_SIZE to 500
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2023-08-18 16:47:53 +07:00
wulan17
9e82bd0b57
Pyrofork: Add alt_port parameter to Client
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2023-08-18 03:30:28 +07:00
mrmissx
5ba8cc48fc
fix: try to handle startup BadMsgNotification #11
Retry to generate a new msg_id to send before raising BadMsgNotification.

Signed-off-by: wulan17 <wulan17@nusantararom.org>
2023-08-18 03:30:27 +07:00
Dan
2ff67c72aa Move the CDN DC IPv6 to the correct mapping 2023-04-30 20:23:42 +02:00
Dan
e24d5b1cf5 Add RSA public keys & IP addresses for some CDN DCs 2023-04-30 19:54:39 +02:00
Dan
245b7e653d Tweak Session timeouts 2023-01-12 18:25:42 +01:00
Dan
d53e1c235b Lower the logging level of some log calls 2023-01-09 15:19:55 +01:00
Dan
6752af8796 Add error messages for transport errors 2022-12-31 19:01:42 +01:00
Dan
cf1e31c413 Apply security checks to each message in the container 2022-12-29 23:33:58 +01:00
Dan
d890e5346c Clear stored_msg_ids on session stop 2022-12-28 17:44:02 +01:00
Dan
1daa05a35c Raise and handle send errors in order to immediately act upon 2022-12-28 00:21:05 +01:00
Dan
5ca422b314 Create a future result before sending its request 2022-12-28 00:19:28 +01:00
Dan
9bf742abc0 Introduce back some previously reverted changes 2022-12-27 13:40:42 +01:00
Dan
bff583ed75 Revert some of the latest changes 2022-12-26 22:26:55 +01:00
Dan
235dde2251 Update exception message 2022-12-26 20:11:58 +01:00
Dan
01cd8bb57f Optimize log calls 2022-12-26 16:38:12 +01:00
Dan
d298c62c6d Update session.py 2022-12-26 16:34:49 +01:00
Dan
ce8c242eb4 Revert to triggering a reconnection when skipping invalid packets 2022-12-25 15:14:12 +01:00
Dan
b23e34494e Add messages for mismatched checks 2022-12-25 15:08:02 +01:00
Dan
ae028ab4b6 Switch back to local system time synchronization
perf_counter will stop counting when the system goes to sleep, causing
the generation of invalid message ids after waking up which in turn put
the client into a never ending reconnecting loop due to check mismatches
caused by the time not being synced anymore. It's also unclear whether
perf_counter stays in sync during long runs.
2022-12-25 14:55:40 +01:00
Dan
4c32a15cfd Remove unneeded threading.Lock 2022-12-25 10:30:56 +01:00
Dan
84d60b56b3 Switch to non-blocking sockets & use a send queue 2022-12-24 16:15:07 +01:00
Dan
b59dcd1615 Do not trigger a reconnection when skipping invalid packets 2022-06-20 09:32:10 +02:00
Dan
7c3c0565b4 Fix wrapped function invocations 2022-05-14 17:29:11 +02:00
Dan
4e1b54288b Fix Client.name usage 2022-04-24 11:56:07 +02:00
Dan
124bcb4db7 Remove API key requirement for existing sessions 2022-04-24 11:56:07 +02:00
Dan
0e3c2e4412 Rename RPCError.x to RPCError.value 2022-04-24 11:56:07 +02:00
Dan
78efb04b40 Rename Client.send to Client.invoke 2022-04-24 11:56:07 +02:00
Dan
dc6c816c80 Revert some of the last changes 2022-02-10 06:44:42 +01:00
Dan
5889c67fb5 Initialize session on reconnection 2022-02-10 05:34:21 +01:00
Stark Programmer
5d155b896c
Add missing await keyword (#898) 2022-02-10 02:22:43 +01:00
Dan
462e5d11a5 Improve stability in case of connection failures 2022-02-10 01:05:36 +01:00
Dan
3a911956b0 Update message for automatic sleeps 2022-01-31 20:45:04 +01:00
Dan
6f9e77bc2c Do not handle messages with a pending ack 2022-01-31 20:42:44 +01:00
Dan
1162e89f26 Better handling of expiring server salts 2022-01-20 09:43:29 +01:00
Dan
626a1bd938 Update copyright year 2022-01-07 10:23:45 +01:00