Multiple connections
See original GitHub issueI have code like this.
const { StringSession } = require('telegram/sessions')
const input = require('input') // npm i input
const apiId = 111111
const apiHash = 'fcf............................'
const stringSession = new StringSession(''); // fill this later with the value from session.save()
(async () => {
console.log('Loading interactive example...')
const client = new TelegramClient(stringSession, apiId, apiHash, { connectionRetries: 5 })
await client.start({
phoneNumber: async () => await input.text('number ?'),
password: async () => await input.text('password?'),
phoneCode: async () => await input.text('Code ?'),
onError: (err) => console.log(err),
});
console.log('You should now be connected.')
console.log(client.session.save()) // Save this string to avoid logging in again
async function eventPrint(event: NewMessageEvent) {
console.log(event.message);
};
client.addEventHandler(eventPrint, new NewMessage({ chats: [chatId] }));
})()
When i run this code on express server in different por only work last telegram. That is, the last running one always works, the previous ones do not work. It feels like the new connection is killing the old one. How to solve the problem with multi-connection?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Windows: Fix 'Multiple connections to a server or shared ...
Multiple connections to a server or shared resource by the same user, using more than one user name are not allowed.
Read more >Multiple connections to a server or shared resource by the ...
On our server we get this error: "Multiple connections to a server or shared resource by the same user, using more than one...
Read more >Multiple Connections - Mothers of Multiples - Home - Facebook
Founded in 1961, Multiple Connections, Inc. has been educating and supporting mothers, and expecting mothers, of multiples (twins, triplets and other ...
Read more >Multiple Connection to a server or shared resource
“Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed.
Read more >Multiple connections to a server or shared resource by the ...
Multiple connections to a server or shard resource by the same user, using more than one user name, are not allowed.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you can’t run the same session multiple times. Telegram will only send updates to the latest running client.
if you want to receive updates you’ll need a new session for each client (even if it’s the same account).
GramJS returns a SessionString that you can save in your DB if you want.
you can use the same session string in the same IP to send messages
You would need a different session string if you want to receive messages/updates. it’s a telegram limitation