pycryptobot: ConnectionError(ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')))

sometimes i get this error:

2021-06-26 03:32:33 | ETHUSDT | 1h | Current Price: 1827.29 ConnectionError(ProtocolError(‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))) Traceback (most recent call last): File “/usr/local/lib/python3.9/ssl.py”, line 1099, in read return self._sslobj.read(len, buffer) ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/usr/local/lib/python3.9/ssl.py”, line 1099, in read return self._sslobj.read(len, buffer) urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))

the error may appear after a few minutes, or the next day

i am using docker: docker run --name ETH -v /root/pycryptobot/config.json:/app/config.json -d ghcr.io/whittlem/pycryptobot/pycryptobot:latest --selllowerpcnt -2 --smartswitch 1 --disablebullonly; docker logs -f ETH

conf.json

{ “binance” : { “api_url” : “https://api.binance.com”, “api_key” : “”, “api_secret” : “”, “config” : { “base_currency” : “ETH”, “quote_currency” : “USDT”, “granularity” : “1h”, “live” : 1, “verbose” : 1, “sellatloss” : 1 } }, “telegram” : { “token” : “”, “client_id” : “” } }

this is normal? or am I doing something wrong? I have been using the bot for 2 days, and during this time it has not made a single transaction on the exchange, thanks

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (4 by maintainers)

Most upvoted comments

You can’t specify it in the config, it’s hardcoded here as far as I know: https://github.com/whittlem/pycryptobot/blob/ef49fee04ef5952c08f66d45ba69cc286b1d4324/pycryptobot.py#L753

s.enter(60, 1, executeJob, (sc, app, state))

The 60 is the delay time in seconds of the scheduler.

Yeah, i’m getting this error as well every few hours.

2021-06-28 22:57:06 | RUNEUSDT | 1h | Current Price: 6.409
ConnectionError(ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')))
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

Some times it doesn’t crash, it outputs this error but resumes trading after 1 minutes.

Exception: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Error on creating instance of AuthAPI Client. Trying again... Attempt: 0
Your connection to the exchange has gone down, will retry in 1 minute!

Forgot to mention this is on binance exchange don’t know if it happens with coinbase pro as well.

No docker, no python venv, just using pure python3.9 pycryptobot.py.

i am getting that error to after bot running some hours. Dint get if is random issue or like a long bot running time?

PS: I not using Docker! using .venv session

Just tried downgrading urllib to version 1.26.0 with pycryptobot version 2.38.0 and no longer have the above issue.

Can confirm, mine also crashed again after around 2 days. Really strange …

I guess another problem is that the auto restart also doesn’t seem to work. Maybe we could catch the Connection error and automatically retry a few times?! Not sure that’s the best idea though…

apparently it now saves the position after crashing, so if you run it on screen like I do, just do a loop and it restarts automatically while true; do python3.9 pycryptobot.py && break; done until you cancel it.

i am testing this method… A solution, but not THE solution.

https://github.com/yanone/raspberrypycryptobot#running-pycryptobot-on-boot

That’s an interesting idea 😃 I will try this as well 👍

I guess it shouldn’t be too hard to implement this as a config option as well.

I’m thinking this has nothing to do with the bot, but with the exchange itself. I figure they have a client timeout. If Binance has a system that resets the peer(us) connection when it fails to respond in a certain amount of time, then their system will terminate the connection after X amount of fails or delays in XX hours. And on our side we see Connection reset by peer, peer as in remote system meaning Binance terminated the connection, not the bot. – I have no clue if this is true, haven’t even read binance’s api docs, and not sure if this is specified there, Dyor. –

Following what @jensb89 said (thanks), I did the opposite. So instead of increasing pool time I reduced it to basically half, which is 30 (do or die) (line 753 of pycryptobot.py like this: s.enter(30, 1, executeJob, (sc, app, state)) ) , and what’ya know, my bot is running live for more than 48h now and connection hasn’t dropped yet. I also checked the log to make sure it hadn’t lost the connection at some point and then reconnected but and no sign of 1 single fail.

I’m sure this is just a temporary fix, but I suggest for this to be implemented as an option in config.json "pooltime": '60', in the next release, otherwise doing a git pull will overwrite this change…this is assuming it’s the real deal which I think it is.

Have the same error on my Pi in a venv environment. I will now set the poll cycle to 2min instead of 1min. I noticed my old coinBase Bot (not updated for some time) also uses 2min update cycle. I think the error is from Binance, maybe it’s too many API calls?

Will let you know if this solves the error for me, for now it’s running 😃