Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client not starting on Docker containerization #637

Open
francestu96 opened this issue Feb 9, 2024 · 6 comments
Open

Client not starting on Docker containerization #637

francestu96 opened this issue Feb 9, 2024 · 6 comments

Comments

@francestu96
Copy link

I have this simple code:

const client = new TelegramClient(new StoreSession("my_session"), parseInt(process.env.API_ID), process.env.API_HASH, {
    connectionRetries: 5,
});

(async () => {
    await client.start({
        phoneNumber: async () => await input.text("Please enter your number: "),
        password: async () => await input.text("Please enter your password: "),
        phoneCode: async () => await input.text("Please enter the code you received: "),
        onError: (err) => console.log(err),
    });

    console.log("You should now be connected.");

    await client.sendMessage("me", { message: "test" });
    console.log("Sent to me.");
})()

It perfectly works without containerization. I want to create a Docker container with this code but it looks like it stucks on client.start function. This is the container log:

2024-02-08 17:42:34 [2024-02-08T16:42:34.106] [INFO] - [Running gramJS version 2.19.9]
2024-02-08 17:42:34 [2024-02-08T16:42:34.119] [INFO] - [Connecting to 91.108.56.132:80/TCPFull...]
2024-02-08 17:42:34 [2024-02-08T16:42:34.125] [INFO] - [Connection to 91.108.56.132:80/TCPFull complete!]
2024-02-08 17:42:34 [2024-02-08T16:42:34.134] [INFO] - [Using LAYER 166 for initial connect] 

It doesn't even print "You should now be connected".
I took care of copying into the image also "my_session" in order to avoid the need to login again.

This is the Dockerfile:

FROM node:18-alpine

WORKDIR /telegrambot

COPY ./bot.js ./package.json .
COPY ./my_session ./my_session

RUN npm install

CMD [ "node", "bot.js" ]

What does it could be the problem?

Thank you in advance!

@Inbell1s
Copy link

Inbell1s commented Mar 6, 2024

Having the exact same issue here.

Node Version v20.11.0
Docker Version 24.0.7

@alvvaysxxx
Copy link

i suppose that may be because of deprecated input(). You can try fixing it manually

@francestu96
Copy link
Author

Still not working even with readline...
Moreover, the input() is not supposed to be called since I copied the session and it doesn't need to call it

@francestu96
Copy link
Author

francestu96 commented Apr 25, 2024

I even tried with a StringSession and used it to connect. Than called await client.start() without any parameters and it successfully connect, yet no way to proceed nor to add a listener for new messages... same output of before

Is it possible it is some Docker port mapping problem? This is getting me crazy

@polRk
Copy link

polRk commented May 9, 2024

I have the same issue. I do not use any readline or something, because i send session from file directly, and call client.connect()

@PeterVoronov
Copy link

Did you tried to run the docker image in interactive mode?
I.e.

docker run -it image_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants