Telethon: ConnectionResetError
I am trying a simple code from the github instructions and I just keep getting ConnectionResetError. I am using Python3.x and installed telethon by using pip3 install… its upgraded version. I just cant get beyond this for some reason. Please help.
from telethon import TelegramClient
# Use your own values here
api_id = xxxxxx
api_hash = 'xxxx'
phone_number = '+91xxxxx'
client = TelegramClient(phone_number, api_id, api_hash)
client.connect()
client.send_code_request(phone_number)
myself = client.sign_in(phone_number, input('Enter code: '))
Here is my entire error that i get.
C:\Users\Administrator>python D:\Fazal\goog\Python\telemembers.py Traceback (most recent call last): File “D:\Fazal\goog\Python\telemembers.py”, line 22, in <module> client.send_code_request(phone_number) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\telegram_client.py”, line 135, in send_code_request result = self(SendCodeRequest(phone, self.api_id, self.api_hash)) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\telegram_bare_client.py”, line 461, in call sender, call_receive, update_state, *requests File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\telegram_bare_client.py”, line 481, in _invoke sender.send(*requests) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\network\mtproto_sender.py”, line 91, in send self._send_message(message) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\network\mtproto_sender.py”, line 141, in _send_message self.connection.send(result) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\network\connection.py”, line 182, in _send_tcp_full self.write(data + crc) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\network\connection.py”, line 219, in _write_plain self.conn.write(data) File “C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-p ackages\telethon\extensions\tcp_client.py”, line 85, in write raise ConnectionResetError() ConnectionResetError
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 30 (14 by maintainers)
Commits related to this issue
- Use ._logger.exception when .connect fails (#373) — committed to LonamiWebs/Telethon by Lonami 7 years ago
I have sovled my problem, if you use proxy such as Shadowsocks etc. You should execute as follow instead of
TelegramClient('session_name', api_id, api_hash)
:TelegramClient('session_name', api_id, api_hash, proxy=(socks.SOCKS5, 'xx.xx.xx.xxx', 4xxx1), update_workers=4)
the ‘xx.xx.xx.xxx’ write down by ‘localhost’, port is your own listened port number, others keep the same! GOOD LUCK!