aahnik / tgcf

The ultimate tool to automate custom telegram message forwarding. Live-syncer, Auto-poster, backup-bot, cloner, chat-forwarder, duplicator, ... Call it whatever you like! tgcf can fulfill your custom needs.
https://github.com/aahnik/tgcf/wiki
MIT License
1.29k stars 775 forks source link

TGCF not forwarding any messages (deployed on Replit) #469

Closed iamyashg closed 1 year ago

iamyashg commented 1 year ago

I have deployed tgcf on replit (it's always on as I have hacker plan).

Its not forwading any message from source to destination

Below are the logs :

                INFO     Loaded plugin replace     __init__.py:98
                INFO     using session string       config.py:212
                INFO     Connecting to       mtprotosender.py:226
                         149.154.167.51:443/                     
                         TcpFull...                              
                INFO     Connection to       mtprotosender.py:277
                         149.154.167.51:443/                     
                         TcpFull complete!                       
                INFO     The server closed the  connection.py:335
                         connection                              
                INFO     Connection closed   mtprotosender.py:507
                         while receiving                         
                         data                                    
                INFO     Closing current     mtprotosender.py:350
                         connection to begin                     
                         reconnect...                            
                INFO     Connecting to       mtprotosender.py:226
                         149.154.167.51:443/                     
                         TcpFull...                              
                INFO     Connection to       mtprotosender.py:277
                         149.154.167.51:443/                     
                         TcpFull complete!

Check below discussion for more info on this..

Originally posted by @iamyashg in https://github.com/aahnik/tgcf/discussions/463

iamyashg commented 1 year ago

Team Replit Answer on this Telethon/Pyrogram Issue —

We have identified the issue. To combat abuse, we require all HTTP traffic to have either an SNI (Server Name Identification) or a Hostname header. Pyrogram connects to raw IP addresses without specifying an SNI or a Hostname header.

The issue here is that Pyrogram will need to update its codebase to support this, or users who intend to run Telegram bots on Replit will need to use a library other than Pyrogram (that is until they fix the issue) if they intend to host their Repl without using Deployments.

Source: https://ask.replit.com/t/pyrogram-network-issue/33679/38

We only allow HTTP traffic out of HTTP ports, such as 443. The issue here is that Telegram clients such as Pyrogram use MTProto (not HTTP) for their connection but run it through 443. So that is why changing the port from 443 to 5222 will work, as we won’t force it to be HTTP traffic.

Source: https://ask.replit.com/t/pyrogram-network-issue/33679/46

Final Solution for TGCF Part —

  1. Click on three dots then show hidden files, now go to below file path.

File Path: venv/lib/python3.10/site-packages/telethon/network/connection/connection.py

  1. Go to line no. 219

  2. Edit the port=self._port, to port=5222,