Running a python based Discord bot on a DigitalOcean Droplet causes a "Connection reset by peer" error not present when running locally

0

Edit: The script was running from a virtual environment on the Droplet, switching to a standard folder system seems to have resolved the issue, will close this question if further testing confirms this.

Sorry if this would be better on Stack Overflow, but as the error appears to be due to running a functioning script in a different environment, this looked like a better fit.

I created a python script to manage a Discord bot using the discord.py api. The primary function of the bot is to translate English words into a glyph based conlang. When running on my local system (win 8.1) this process executes correctly, but when running from the droplet (Ubuntu 18.04), the bot frequently fails to respond to translation commands, and eventually this error log appears in the console:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/synake/pybot/six/lib/python3.6/site-packages/discord/client.py", line 255, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 61, in on_message
    await message.channel.send(file=discord.File("ancient.png"), content = rep.str1)
  File "/home/synake/pybot/six/lib/python3.6/site-packages/discord/abc.py", line 759, in send
    content=content, tts=tts, embed=embed, nonce=nonce)
  File "/home/synake/pybot/six/lib/python3.6/site-packages/discord/http.py", line 158, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "/home/synake/pybot/six/lib/python3.6/site-packages/aiohttp/client.py", line 1005, in __aenter__
    self._resp = await self._coro
  File "/home/synake/pybot/six/lib/python3.6/site-packages/aiohttp/client.py", line 497, in _request
    await resp.start(conn)
  File "/home/synake/pybot/six/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 844, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/home/synake/pybot/six/lib/python3.6/site-packages/aiohttp/streams.py", line 588, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

As I understand it this is due to Discord closing the connection on their end. My confusion is that I am unable to replicate the error when running the bot from my local system. Research lead me to investigate if I was exceeding the message limit rate Discord sets, but the discord.py api is supposed to manage that automatically, and even triggering the translate function rapidly did not result in a connection error on the local system.

I am new to both Ubuntu and VMs so this may be a simple issue I am unaware of, but I am at a loss how to trouble shoot further.

SkepticMech

Posted 2019-04-25T00:39:08.223

Reputation: 1

No answers