wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
990 stars 163 forks source link

An exception occured in the reactor: WTelegram.WTException: Cannot find type for ctor #whatever after upgrading to v4.x #255

Closed 13xforever closed 4 months ago

13xforever commented 5 months ago

In #191 it is stated:

In which case, some errors like this may show up ONLY in the logs and WTelegramClient should be able to ignore the errors and continue execution normally

But I've tried to upgrade twice from 3.7.2 (first to 4.0, and today to 4.1.1), and all I get are these exceptions and no events being triggered in OnUpdates at all, so basically nothing works, and rolling back eats the events that were received by 4.x client.

full stack trace I get in the logs on new message:

2024-05-07 23:03:55.5380    322 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:03:55Z   
2024-05-07 23:03:55.5380    323 DEBUG [telegram] Received 1 update 
2024-05-07 23:03:55.5380    324 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:03:56.2067    325 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:03:56Z   
2024-05-07 23:03:56.2067    326 DEBUG [telegram] Received 1 update 
2024-05-07 23:03:56.2067    327 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:03:57.9074    328 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:03:57Z   
2024-05-07 23:03:57.9074    329 DEBUG [telegram] Received 1 update 
2024-05-07 23:03:57.9074    330 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:02.5773    331 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:04:02Z   
2024-05-07 23:04:02.5773    332 DEBUG [telegram] Received 1 update 
2024-05-07 23:04:02.5773    333 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:02.9091    334 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:04:02Z   
2024-05-07 23:04:02.9091    335 DEBUG [telegram] Received 1 update 
2024-05-07 23:04:02.9091    336 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:10.2425    337 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:04:10Z   
2024-05-07 23:04:10.2425    338 DEBUG [telegram] Received 1 update 
2024-05-07 23:04:10.2425    339 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:16.5337    340 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:04:16Z   
2024-05-07 23:04:16.5337    341 DEBUG [telegram] Received 1 update 
2024-05-07 23:04:16.5337    342 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:39.2969    343 DEBUG [spam] 2>Receiving UpdateShort                              2024-05-07 18:04:39Z   
2024-05-07 23:04:39.2969    344 DEBUG [telegram] Received 1 update 
2024-05-07 23:04:39.2969    345 DEBUG [telegram] Ignoring update of type UpdateUserStatus 
2024-05-07 23:04:39.3283    346 FATAL [spam] 2>An exception occured in the reactor: WTelegram.WTException: Cannot find type for ctor #a66c7efc
   at TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
   at TL.UpdateNewChannelMessage.ReadTL(BinaryReader reader)
   at TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
   at TL.Serialization.ReadTLValue(BinaryReader reader, Type type)
   at TL.Serialization.ReadTLVector[T](BinaryReader reader)
   at TL.Updates.ReadTL(BinaryReader reader)
   at TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
   at WTelegram.Client.ReadFrame(Byte[] data, Int32 dataLen)
   at WTelegram.Client.Reactor(Stream stream, CancellationTokenSource cts) 
2024-05-07 23:04:45.3452    347 INFO  [spam] Connecting to 149.154.167.41:443... 
2024-05-07 23:04:45.3566    348 DEBUG [spam] 2>Sending   InvokeWithLayer`1                        #9F99 
2024-05-07 23:04:45.4182    349 DEBUG [spam] 2>Receiving MsgContainer                             2024-05-07 18:04:45Z (svc) 
2024-05-07 23:04:45.4182    350 DEBUG [spam]             → UpdateShort                            2024-05-07 18:03:55Z   
2024-05-07 23:04:45.4182    351 DEBUG [spam]             → UpdateShort                            2024-05-07 18:03:56Z   
2024-05-07 23:04:45.4195    352 DEBUG [spam]             → UpdateShort                            2024-05-07 18:03:57Z   
2024-05-07 23:04:45.4195    353 DEBUG [spam]             → UpdateShort                            2024-05-07 18:04:02Z   
2024-05-07 23:04:45.4195    354 DEBUG [spam]             → UpdateShort                            2024-05-07 18:04:02Z   
2024-05-07 23:04:45.4195    355 DEBUG [spam]             → UpdateShort                            2024-05-07 18:04:10Z   
2024-05-07 23:04:45.4195    356 DEBUG [spam]             → UpdateShort                            2024-05-07 18:04:16Z   
2024-05-07 23:04:45.4195    357 DEBUG [spam]             → UpdateShort                            2024-05-07 18:04:39Z   
2024-05-07 23:04:45.4195    358 DEBUG [spam]             → MsgNewDetailedInfo                     2024-05-07 18:04:45Z (svc)  
2024-05-07 23:04:45.4195    359 DEBUG [spam]             → MsgNewDetailedInfo                     2024-05-07 18:04:45Z (svc)  
2024-05-07 23:04:45.4195    360 DEBUG [spam]             → MsgNewDetailedInfo                     2024-05-07 18:04:45Z (svc)  
2024-05-07 23:04:45.4195    361 DEBUG [spam]             → MsgsAck            
oscartorres9 commented 5 months ago

exact same error! how to fix it, any ideas?

13xforever commented 5 months ago

This issue specifically about OnUpdates not being triggered, for general issue please see pinned #191

devtunnelx commented 5 months ago

I'm having similar issue

Version: 4.1.1

4>An exception occured in the reactor: WTelegram.WTException: Cannot find type for ctor #86e18161
TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
TL.MessageMediaPoll.ReadTL(BinaryReader reader)
TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
at TL.Message.ReadTL(BinaryReader reader)
TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
TL.Serialization.ReadTLVector[T](BinaryReader reader)
TL.Updates.ReadTL(BinaryReader reader)
TL.Serialization.ReadTLObject(BinaryReader reader, UInt32 ctorNb)
WTelegram.Client.ReadFrame(Byte[] data, Int32 dataLen)
WTelegram.Client.Reactor(Stream stream, CancellationTokenSource cts)
13xforever commented 4 months ago

Ok, idk how useful this issue anymore, since the old version of the client stopped receiving new message updates yesterday.

Anyway, in case this is indeed related to the old serialized data, a reminder that you can force a clean start by removing your WTelegram.session file and logging back again using the new client version. I can't say if the new version fixes the missing updates yet, but either way I think everyone will be forced to upgrade soon.

wiz0u commented 4 months ago

I can't tell anything wrong from your logs and without seeing your program. I'd guess you forgot to reassign .OnUpdates after recreating the client on ReactorError.

13xforever commented 4 months ago

I do not recreate the client, at worst I restart the whole app. After upgrading to 4.1.1 and removing all state, there are no deserialization errors, but I still do not get any events in OnUpdates, and as you said yourself, there's absolutely nothing in the logs. I'm pretty sure it's the issue with redesigned event handling in v4 in general.

wiz0u commented 4 months ago

You should catch OnOther(ReactorError) and at minimal log that error, or else you might be missing an important piece of info that might explain why your Client seems totally disabled. See Examples/Program_ReactorError.cs

There was no event redesign in v4, only renamed OnUpdate => OnUpdates (UpdateManager code is independent from Client code, and you don't seem to use it)