Network issue in Pyrogram - Replit

Problem description:
For the last few weeks, I’ve been getting Network issues while using pyrogram library in python. I’ve even tested this with my account with Pro plan, but the same result.

Expected behavior:
The code should just run fine without issues. As it works just fine in my computer or in other cloud hosting services.

Actual behavior:
Sometimes it gives KeyError: 0 which is a network issue as described in pyrogram discussion.
And sometimes it just keeps repeating
Network task started

Steps to reproduce:

from pyrogram import *
import logging, os

logger = logging.getLogger(__name__)
logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)


api_id = 25650897
api_hash = "9a1ef2625e3afc3be978808117786ceb"
token = os.environ.get("TOKEN")

app = Client("test", api_id=api_id, api_hash=api_hash, bot_token=token, in_memory=True)


@app.on_message(filters.text)
async def echo(_, m):
    await m.reply(m.text)


app.run()

Bug appears at this link:

https://replit.com/@iamthesadik/Pyro

Browser/OS/Device:
Replit Repo | Linux

did you manage to solve it ? I am also facing the same issue

store your token in a secret named TOKEN. Remove that line from your code


2 Likes

Problem description:
For the last few weeks, I’ve been getting Network issues while using pyrogram library in python. I’ve even tested this with my account with Pro plan, but the same result.

Expected behavior:
The code should just run fine without issues. As it works just fine in my computer or in other cloud hosting services.

Actual behavior:
Sometimes it gives KeyError: 0 which is a network issue as described in pyrogram discussion.
And sometimes it just keeps repeating
Network task started

Steps to reproduce:

from pyrogram import *
import logging, os

logger = logging.getLogger(__name__)
logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    level=logging.INFO)


api_id = [Redacted]
api_hash = "[Redacted]"
token = os.environ.get("TOKEN")
token = "[Redacted]"

app = Client("test", api_id=api_id, api_hash=api_hash, bot_token=token, in_memory=True)

@app.on_message(filters.text)
async def echo(_,m):
	await m.reply(m.text)

app.run()

Bug appears at this link:

https://replit.com/@iamthesadik/Pyro

Browser/OS/Device:
Replit Repo | Linux