Code Monkey home page Code Monkey logo

Comments (13)

painor avatar painor commented on July 28, 2024

strange. do you know what was the API call you made ? also did you change anything when creating the constructor ?
as for the logger you can import the Logger class and use Logger.setLevel("anything here"); to remove it. there are 4 levels
levels = ['error', 'warn', 'info', 'debug'];

from gramjs.

maheshbansod avatar maheshbansod commented on July 28, 2024

The API call was users.GetFullUser
I made a smaller node js application to reproduce it:

const { TelegramClient } = require('telegram/dist')
const { StringSession } = require('telegram/dist/sessions');
const teletl = require('telegram/dist/tl');
const readline = require('readline');
const { Logger } = require('telegram/dist/extensions');

const apiId = process.env.API_ID // put your api id here [for example 123456789]
const apiHash = process.env.API_HASH // put your api hash here [for example '123456abcfghe']
const client = new TelegramClient(new StringSession(process.env.STRING_SESSION), apiId, apiHash, {
    connectionRetries: 3,
})

var username = 'justanotherlight';
client.start();
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});


Logger.setLevel("debug");

rl.question('make getfulluser? y for yes ', async (choice) => {

    if (choice != 'y') {
        return;
    }
    client.invoke(new teletl.Api.users.GetFullUser({ id: username }))
        .then((res) => console.log(res))
        .catch((err) => {
            console.log(err);
        });

    rl.close();
});

Apparently making multiple requests one after the other works if I do it in the above code, but if I wait and do nothing for like 30 seconds, it shows this

[2021-03-11T11:23:15.453Z] [INFO] - [connection closed]
{ Error: Invalid checksum (2699144061 when 2396756994 was expected). This packet should be skipped.
    at FullPacketCodec.<anonymous> (/home/null/apps/test-gramjs/node_modules/telegram/dist/network/connection/TCPFull.js:53:23)
    at Generator.next (<anonymous>)
    at fulfilled (/home/null/apps/test-gramjs/node_modules/telegram/dist/network/connection/TCPFull.js:5:58)
    at process._tickCallback (internal/process/next_tick.js:68:7) checksum: 2699144061, validChecksum: 2396756994 }

does it mean that I should do a client.start for every request if the requests are not that frequent(like a few minutes to a few hours)?

from gramjs.

painor avatar painor commented on July 28, 2024

that's very weird. I tried your code and it's been running fine for 10 min. are you sure you're not using a VPN or have an IPV6 or something weird like that ?

from gramjs.

maheshbansod avatar maheshbansod commented on July 28, 2024

Yea no it doesn't I think, one network I tried on had IPv6, but it had the same error as with the IPv4 one. Putting it on Heroku gives me the same thing too. So basically I see the same error message on different networks and different machines, so I can't make more than one request since the client is disconnected. Also, I don't use a VPN.
What should I be doing to fix this?
Is there any more information that I can provide to solve this problem?

from gramjs.

plukito avatar plukito commented on July 28, 2024

Also get this error. In my case I called messages.GetHistory

await telegram.invoke(new Api.messages.GetHistory({
    peer: new Api.InputPeerChat({
        chatId: parseInt(id)
    })
}));

from gramjs.

painor avatar painor commented on July 28, 2024

well one thing for sure is that ipv6 is not supported.
As for getHistory try to pass the id directly instead of an InputPeerChat. It's very weird that this is happening.

from gramjs.

plukito avatar plukito commented on July 28, 2024

Yes, already tried that, but got the same error. Is there any recommendation?

from gramjs.

painor avatar painor commented on July 28, 2024

which error are you getting btw the disconnect one ?

from gramjs.

plukito avatar plukito commented on July 28, 2024

same as the author, the Invalid checksum error

from gramjs.

plukito avatar plukito commented on July 28, 2024

I reinstalling everything and I haven't found any issue from checksum error.

All I did are removing yarn.lock and node_modules then ran yarn install

Thank you for your help @painor

from gramjs.

plukito avatar plukito commented on July 28, 2024

Sorry, seems the invalid checksum error is reapearring this morning. I suspect the network, but then I tried to run the same function in telethon and it ran successfully.

Does anyone have any idea why does this error reoccurring despite having no code changes?

from gramjs.

painor avatar painor commented on July 28, 2024

I think the issue was in the TCP connection reader on slower connections. It might have been fixed in latest patch. you could also use connection:ConnectionTCPObfuscated in the args to try if it's better.
const client = new TelegramClient(new StringSession(stringSession), apiId, apiHash, { connection:ConnectionTCPObfuscated })

from gramjs.

maheshbansod avatar maheshbansod commented on July 28, 2024

Yes, looks like it's fixed now. Thanks!

from gramjs.

Related Issues (20)

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.