LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
683 stars 164 forks source link

WARNING:urllib3.connectionpool:Connection pool is full #80

Closed enarjord closed 3 years ago

enarjord commented 4 years ago

Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])

Select one:

Environment

Operating System? (include version)

Python Version Requirement

Exact Python Version?

Include here the response of 'python --version' or 'python3 --version'
Python 3.8.2

Pip Version?

Include here the response of 'pip --version' or 'pip3 --version'
pip 20.1.1

Dependencies

Run pip list > pip_list.txt and upload the file. pip_list.txt

UNICORN Binance WebSocket API Version?

Did you upgrade to the latest release version with `pip install unicorn-binance-websocket-api --upgrade`?

Please control what version you are using with this script and post the output: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/tools/get_used_module_version.py

1.15.0

Description of your issue

when streaming binance's partial book depth with 25 symbols i get the following warning, lots of them in the beginning, thereafter sporadically

WARNING:urllib3.connectionpool:Connection pool is full, discarding connection: api.binance.com

everything still works fine, but the warning is annoying

i've looked around and apparently the problem has to do with how many connections urllib3 pool manager can have

is there something to do or a way to suppress the warnings?

thanks

Include the contents of the log here (if applicable). < REPLACE THIS TEXT
oliver-zehentleitner commented 4 years ago

Its a WARNING of the logging module. You can control the logging module by setting the logging level like: logging.basicConfig(level=logging.ERROR, filename=os.path.basename(file) + '.log', format="{asctime} [{levelname:8}] {process} {thread} {module}: {message}", style="{")

https://docs.python.org/3/library/logging.html#logging-levels

But its currious, i stream depth of more than 700 pairs and I dont get that issue and if I were you, I would try to find the reason, because with this issue the lib is not able to communicate with the REST API and this should be a problem from my point of view.

I can help you better, if you provide me your code...

Best regards, Oliver

enarjord commented 4 years ago

Hi Oliver,

thanks for prompt response,

I've been using this lib https://github.com/sammchardy/python-binance

in my bot, and i wanted to try other options because i had some trouble with it.

yours worked better, more robust and easier to start and stop

here is my project: https://github.com/enarjord/passivbot

see streamer.py in the branch new_streamer for the code which produces the warning

all the best

oliver-zehentleitner commented 4 years ago

Cool bot! Does it work well?

i have read the code in https://github.com/enarjord/passivbot/blob/new_streamer/streamer.py and I think this is not coming from unicorn lib. You are only using depth and the unicorn lib only needs the rest api if you start a user data stream.

Did you ever determine where this issue is coming from?

Maybe you can try it with not using ccxt? Because https://github.com/enarjord/passivbot/blob/new_streamer/commons.py#L15 is doing some rest api calls.

oliver-zehentleitner commented 4 years ago

Just a little hint, .lower is not needed for trading pairs, because the lib is doing it already.

enarjord commented 4 years ago

thanks!

the bot works well yes, been running this one a few weeks, an earlier version which was long only for a few months before that

no, haven't determined the source of the issue yet, i'll look more into it when time allows

the warning was not there before switching from sammchardy's stream api to unicorn api.

anyways, thank you helpful answers and feel free to try out the bot

oliver-zehentleitner commented 4 years ago

Your welcome!

I will try it as soon as possible, already added your repo to my favourites :)

oliver-zehentleitner commented 4 years ago

I wanted to reproduce this issue and investigate it, but you removed the branch?

enarjord commented 4 years ago

yes, i removed the branch, and now i cannot find a way to restore it again :/

so i wrote it anew. i called the branch "unicorn_streamer". it still produces the warning for me

by the way, i also discovered that using the unicorn lib made the bot use way too much cpu, compared to sammchardy's lib

therefore, instead of investigating further, i decided to take the opportunity to learn how to make the streamer myself using python's websockets module

i haven't written it yet, so i'm using sammchardy's lib meanwhile learning how asyncio works

oliver-zehentleitner commented 4 years ago

thank you! will pick it up soon!

oliver-zehentleitner commented 4 years ago

I tested on linux with python 3.7.1, because I need some days to get to my macbook ...

I did:

git clone --single-branch --branch unicorn_streamer https://github.com/oliver-zehentleitner/passivbot.git  
python3 -m pip install ccxt python-binance

I created a the file oliver.json in api_key_secrets/binance and started ./passivbot.py oliver and get:

 ./passivbot.py oliver
from: can't read /var/mail/common_procedures
from: can't read /var/mail/common_functions
from: can't read /var/mail/binance.websockets
from: can't read /var/mail/typing
from: can't read /var/mail/time
from: can't read /var/mail/commons
from: can't read /var/mail/vwap
from: can't read /var/mail/streamer
import: not authorized `sys' @ error/constitute.c/WriteImage/1028.
import: not authorized `json' @ error/constitute.c/WriteImage/1028.
./passivbot.py: Zeile 13: Syntaxfehler beim unerwarteten Wort `('
./passivbot.py: Zeile 13: `def load_settings(user: str):'

then it stopps.

I will try again on my macbook in a few days.

enarjord commented 4 years ago

there is use of assignment expressions, :=, in the code, which requires python >= 3.8

i tried starting it by the command ./passivbot.py username instead of python3 passivbot.py username and i get permission denied errors

oliver-zehentleitner commented 3 years ago

I tested it with my mac book on python 3.8.5, a fresh installation of ccxt, python-binance and unicorn-binance-websocket-api.

Then i cloned https://github.com/oliver-zehentleitner/passivbot changed to the unicorn_streamer branch and tested it and it worked on my system.

If some one is experiencing this again, please feel free to reopen.