Giter Site home page Giter Site logo

Comments (24)

andrew-ld avatar andrew-ld commented on July 24, 2024

the problem is that mtproto requires you to update the client's salt every 30 minutes with one communicated by the server, this salt is actually usable by the client for 60 minutes but after 30 minutes the server starts sending you replies with the new salt.

The mtproto client has to ask for the new salt before the current one expires, but if get_future_salts doesn't get an answer when it starts (sometimes it has happened to me), this request will never be made.

However, after 60 minutes as the current salt will no longer be accepted and the mtproto client will be forced to update the salt with a new one communicated by the server, in which case my client can still manage it, the only annoyance being the error log.

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

4a38bfe

I have modified how the client requests a salt from the mtproto server, I have made that if I do not receive a reply within 30 seconds I re-execute another request, so as to avoid your case where the client is left with an old server_salt because get_future_salts has not replied and still the mtproto server accepts the old salt but only replies with a new one

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

@iamDonkey can try?

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

@iamDonkey can try?

I will try soon and let you know

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

still getting this error endlessly i noticed it starts to give error around 20mins after launch.

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

Can you send me debug level logs from client startup until this happens

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

proper functioning of the client should look like this

(30 minutes later)
DEBUG:root:sending message (ping) 7100142388728814516 to mtproto
DEBUG:root:received message (pong) 7100142388872326145 from mtproto
DEBUG:root:pong message: -7104915902057347489
DEBUG:root:sending message (get_future_salts) 7100142502120849004 to mtproto
ERROR:root:received a message with unknown salt! -3968728431761421443
DEBUG:root:received message (future_salts) 7100142502301487105 from mtproto
DEBUG:root:scheduling get_future_salts, current salt is valid for 1801 seconds

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

I am doing more tests i will post update soon.

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

hi @andrew-ld
fresh log here https://pastebin.com/raw/sMZxy1Gk
this time error came after 24mins
running another test and will post result in next 30 mins.

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

another log https://pastebin.com/raw/fWZC0Fdm
this time error came in 21mins but it must be noted that same error was printed at the time of client launch as well? 🤔
i let it run for more than 30mins and found the error disappear after 30mins as it gets new salt from server
log here https://pastebin.com/raw/qQ785nHa

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

https://core.telegram.org/mtproto/service_messages#request-for-several-future-salts

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

The problem I'm noticing is that the salt can expire even before 30 minutes, I need to be able to handle this case, the problem is that get_future_salts apparently doesn't return the exact time of how long that salt expires so I don't actually know after how long to do it.

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

{'_cons': 'future_salts', 'req_msg_id': 7100299230082561864, 'now': 1653167239, 'salts': [{'_cons': 'future_salt', 'valid_since': 1653166095, 'valid_until': 1653169695, 'salt': -7268505024579983429}, {'_cons': 'future_salt', 'valid_since': 1653167895, 'valid_until': 1653171495, 'salt': -3011236082352035825}]}

according to the received response salt has lifetime of 3600 seconds/60minutes/1hr?

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

The correct solution would be to request 64 future salt and keep them pinned in the client and when I receive a message with a different salt if present in one of these future salts I have to update the salt present in the authkey with the one received

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

@iamDonkey The server accepts the correct salt for 60 minutes however after 30 minutes it already no longer uses it in messages from the server to the client but still the client can continue to use it to send messages to the server, in fact if you see I have a min() in the function that calculates the expiration of the current salt

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

The correct solution would be to request 64 future salt and keep them pinned in the client and when I receive a message with a different salt if present in one of these future salts I have to update the salt present in the authkey with the one received

i think no need extra rpc calls and work.
just replace the client side stored server salt with server returned salt silently if they are not same? and not show any warning or error.
will that work?

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

No better to check with the salts already obtained before, because this is to prevent replay attack, and I think by doing so I would make the client vulnerable to some security bug.

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

if you obtain 64 salts at the launch time how long it can run without sending another get_future_salts i don't like sending additional calls. so far this is the best mtproto library i ever found. it runs on memory as low as 20MB. i hope and wish you will not make this library heavy and hard like other libraries.

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

keeping 64 salt in memory is almost irrelevant in total ram usage

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

I use this library to keep more than 1000 bots connected in parallel without using too much ram, so it will always remain the 'main goal not occupy more RAM than necessary

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

keeping 64 salt in memory is almost irrelevant in total ram usage

Yes but i want to know howlong these 64salts last for?

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

f672064

I may have found a better way, it should work.

from ll-mtproto.

andrew-ld avatar andrew-ld commented on July 24, 2024

from the expiry time of the salt I subtract the current time so that I know when the salt will expire and then remove 1800 seconds, basically removing the time when the salt is valid from the client to the server but not from the server to the client

from ll-mtproto.

iamDonkey avatar iamDonkey commented on July 24, 2024

It's better now.

from ll-mtproto.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.