-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket fails to reconnect #131
Comments
Hi! |
This problem is interesting, do you know a way how to reproduce it? How may open files do you after, if this happens on your system? |
Hi and thanks for the fast reply. I'm going to send the rest of the log file in a few hours. I'm running the websocket in a container to sync the order book. I detected the issue because the order book suddenly stopped changing for more that 40 seconds and that's very unlikly. Sadly I don't know how to reproduce this problem but the websocket for other containers stopped working a few minutes later as well. |
Hi, I just saw that the whole server had a very high cpu usage before this problem popped up. Also I found the line in the log file that initially caused the problem: |
As you may notice it's not from the same container but as I already said, I have multiple containers and all had the same issue. This one just disconnected a few hours after the bch-container. |
could you provide me one full logfile? |
Here you go. Thanks again for your fast answers. |
Hm, I think a problem is that the app doenst get enough cpu power! |
Hello! I think its very clear, from 2020-11-17 01:34:08 to 2020-11-17 22:53:59 your CPU is under full load. As mentioned before, please power up the system, because if you have a constant backlog on the stream your are loosing data more often than necessary. The only handling i can add is a graceful shutdown and a better log msg. Best regards! |
Hi, thanks for the fast fix. I'm planing to switch to a better server and when I do so I will also upgrade unicorn to the newest version. |
Your welcome! 👍 |
Hi, by now I think that the issue, that the websocket fails to reconnect after an error 1006 followed by an interpreter shutdown is related to python 3.9. In your telegram group was a conversation about the same issue and it could be fixed by downgrading to python 3.8. My scripts also didn't fail since I downgraded to python 3.8. |
I leave it open and wait for further confirmations that its a python 3.9 issue. |
can confirm. python3.9 reproduces this error for me. |
I can confirm this as well. |
I have some findings on this topic. On my bot project I got the error at the beginning of the execution and my script couldn't run at all. This is a minimal way for reproducing the issue: from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
API_KEY = '*'
API_SECRET = '*'
binance_websocket_api_manager = BinanceWebSocketApiManager(
exchange='binance.com-futures',
)
binance_websocket_api_manager.create_stream(
channels=['!userData'],
markets=['arr'],
api_key=API_KEY,
api_secret=API_SECRET
)
What I found out is that a simple from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
import time
API_KEY = '*'
API_SECRET = '*'
binance_websocket_api_manager = BinanceWebSocketApiManager(
exchange='binance.com-futures',
)
binance_websocket_api_manager.create_stream(
channels=['!userData'],
markets=['arr'],
api_key=API_KEY,
api_secret=API_SECRET
)
while True:
time.sleep(1) I can't be sure why it works but the issue was fixed on my project once I added a Another thing I found out is that the issue seems to be related with the use of |
Could be solved through #176 Some feedback would be nice! |
I think we are talking past each other :) I started this file on my mac: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/blob/master/dev_test_issue_131_xilopaint.py and it works with the current ubwa version with python3.10.2 |
Really? It doesn't work on my Mac. But my Python version is 3.9.10 installed with Homebrew. |
The one bug in this thead has been fixed, the other one on macOS remains. I need more information please, on my macOS the snippet of xilopaint works fine unfortunately :/ Anyone affected by the bug please update to the latest version of UBWA and post DEBUG logs. Thank you! |
Both issues are fixed now! Thanks @xilopaint for the hints and testing!! |
|
@oliver-zehentleitner @xilopaint @jon4hz I also have this problem.
def execute(self):
self.stream_id = self.manager.create_stream(
channels=['kline_1h'],
markets=self.symbols,
process_stream_data=self.handle_socket_message,
)
monitoring_thread = Thread(target=self.monitoring_streams)
monitoring_thread.start()
# ... another logic ...
def monitoring_streams(self):
while True:
try:
logger.info(self.manager.get_monitoring_status_plain())
logger.info(self.manager.get_stream_list())
logger.info(self.manager.print_summary())
except Exception as e:
logger.exception(e)
time.sleep(15) |
I think the problem can be handled only with complete code. Maybe this approach helps you:
|
thank you sincerely, helped me solve the problem that had been bothering me for two days |
I have published best practice examples for all modules of our suite here: https://medium.lucit.tech/how-to-obtain-and-use-a-unicorn-binance-suite-license-key-and-run-the-ubs-module-according-to-best-87b0088124a8#417c (Will be continuously revised and adapted) I work a lot with the libraries and recommend this approach as it is the most resource-efficient, fastest and most robust - here is the example for UBWA: https://gist.github.com/oliver-zehentleitner/560c102d7867a2743aeba13720e8083b#file-best_practice_ubwa_full-py
|
To explain what is happening here: Even a |
Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])
Select one:
Environment
What kind of internet connection do you have?
~1-2 GB/s
Average system load (CPU)
45%
Hardware specification
VPS, Vultr
Operating System? (include version)
Options
Python Version Requirement
Exact Python Version?
Pip Version?
Dependencies
Run
pip list > pip_list.txt
and upload the file.UNICORN Binance WebSocket API Version?
Description of your issue
The text was updated successfully, but these errors were encountered: