Closed leeweenj closed 3 years ago
Hey @leeweenj
Have you checked docker containers? Are all containers running ok?
@Virkkunen
The error message Error: Timestamp for this request is outside of the recvWindow.
is from Binance API.
It could not receive a response within the expected time.
You will need to try with faster internet.
Can you make sure your server's time is synced?
Refer this - https://github.com/ccxt/ccxt/issues/936#issuecomment-425248158
@chrisleekr of course, all the docker containers works, i still have this problem.
@leeweenj
Look. Even if I want to help you out, I cannot guess what the issue is without more information. Please at least try to find out what the issue is.
I've deleted my previous comments here since they were not entirely related to this issue.
I was facing this same issue on my Arch Linux device, which ran the bot perfectly fine on the stable branch, but when I updated it to the feature-monitoring-simultaneously branch, this error popped up many times in the log and the bot just didn't work.
This is the only error that shows in the log:
[2021-04-27T13:12:22.505Z] ERROR: binance-api/37 on 005bf1645825: Something wrong with trailing-trade-common cache (version=0.0.65, gitHash=unspecified, server=websocket, e={})
payload: {
"command": "latest",
"data": {}
}
I've already tried rebasing the code, rebuilding the container, doing a thorough clean up of every thing related to the bot, container, db and docker on my device, yet the error persists.
I then decided to test it on my Windows device, and did exactly the same thing as I did cloning, building and running it on my Linux device, and it works as it should. It is not ideal for me, and the issue still persists on my Linux device, unfortunately. I'd love to be able to help more, but there isn't much going on other than these few lines of error logs.
@Virkkunen I am using Arch for developing this bot. So it's not an issue what you are using.
You mentioned you were trying to use PR branch #77 and then went back to the master branch?
I know you mentioned cleaned up the container, but have you cleaned container volumes as well? I assume you already know, but let me just write in here the commands:
$ docker-compose -f docker-compose.server.yml down -t1 -v
$ docker-compose -f docker-compose.server.yml pull
$ docker-compose -f docker-compose.server.yml up -d
Assuming you are using the master branch, the error message is coming from this - https://github.com/chrisleekr/binance-trading-bot/blob/master/app/websocket/handlers/latest.js#L47
Yeah, I was using the master branch, tried to update to #77 and I got the error. did the cleanup as far as a docker system prune –af ––volumes
and tried again, to no avail. Since it works just fine on my Windows device by doing exactly the same things I did on my Arch device, I'm thinking that there might be something that wasn't cleaned up.
Still, we don't know why we've got the error in the first place. I'd suggest @leeweenj to try running it and sending logs too, so it's easier to check what's going on.
@Virkkunen Well, sounds like the issue is not related to the bot. I am still happy to find out what went wrong.
So were you using master or #77 branch with Arch?
Can you share your .env
(please remove API key) and which commands you used to launch the bot?
My .env
file:
## Live
BINANCE_LIVE_API_KEY=
BINANCE_LIVE_SECRET_KEY=
## Test
BINANCE_TEST_API_KEY=
BINANCE_TEST_SECRET_KEY=
## Slack
BINANCE_SLACK_WEBHOOK_URL=
BINANCE_SLACK_CHANNEL="#binance"
BINANCE_SLACK_USERNAME=BTB_bot
## Local Tunnel
BINANCE_LOCAL_TUNNEL_SUBDOMAIN=default
I've used docker-compose up -d
and docker-compose -f docker-compose.server.yml up -d
to start the bot (not at the same time), to check and see if there was issue with any of the compose files, but AFAIK there isn't.
Wait, what I wanted to know from .env
is whether you filled API key for live or test.
If you see docker-compose.yml
, BINANCE_MODE
is configured as test
, which you will need the test API key from https://testnet.binance.vision/
If you are using docker-compose.server.yml
, BINANCE_MODE
is live
, which you need API key from Binance - https://binance.zendesk.com/hc/en-us/articles/360002502072-How-to-create-API
If you are not developing, simply use docker-compose.server.yml
. No need to use docker-compose.yml
.
Ah, gotcha. I'm in the live environment, and had edited docker-compose.yml
to reflect that (for those testing purposes). In my .env
I have both live and test keys set, and also slack webhook.
That's ok if you know what you are doing.
The only reason it throws the error Something wrong with trailing-trade-common cache
is when it couldn't get cache from Redis, which is specified in here - https://github.com/chrisleekr/binance-trading-bot/blob/master/app/websocket/handlers/latest.js#L47
And as you can see those are account-info
, exchange-symbols
, local-tunnel-url
, which are from the API.
So my guess in here for you is the API may not configured correctly.
Have you tried to test your API manually?
I haven't tried to test it manually, but I am using the same key as I was when it worked on my Arch device, and it's the same key I am using that is working fine on my Windows device. I haven't touched it ever since I created it, and it is executing the operations just fine.
Actually, let me give you a quick script to find out your API is configured or not. I guess this script will help others to debug in the future. Follow the below commands:
$ docker exec -it binance-bot /bin/ash
/srv$ vi app/scripts/binance-test.js
Paste below script and save
/* istanbul ignore file */
const { binance, logger } = require('../helpers');
(async () => {
logger.info('Test binance');
const accountInfo = await binance.client.accountInfo();
logger.info({ accountInfo }, 'Retrieved account information');
process.exit(0);
})();
And run it.
$ node app/scripts/binance-test.js
{"name":"binance-api","version":"0.0.65","hostname":"2c151c81b838","pid":54,"level":30,"accountInfo":{"makerCommission":0,"takerCommission":0,"buyerCommission":0,"sellerCommission":0,"canTrade":true,"canWithdraw":false,"canDeposit":false,"updateTime":1619554306605,"accountType":"SPOT","balances":[{"asset":"BNB","free":"96.44662180","locked":"0.00000000"},{"asset":"BTC","free":"0.05631199","locked":"0.00000000"},{"asset":"BUSD","free":"25147.19918548","locked":"99.78513600"},{"asset":"ETH","free":"0.00010000","locked":"73.17993000"},{"asset":"LTC","free":"484.43025000","locked":"0.00000000"},{"asset":"TRX","free":"190356.50000000","locked":"0.00000000"},{"asset":"USDT","free":"430457.75093866","locked":"0.00000000"},{"asset":"XRP","free":"199.70000000","locked":"0.00000000"}],"permissions":["SPOT"]},"msg":"Retrieved account information","time":"2021-04-27T22:26:04.284Z","v":0}
If you see a message like above, it means your Binance configuration is correctly set.
I haven't tried to test it manually, but I am using the same key as I was when it worked on my Arch device, and it's the same key I am using that is working fine on my Windows device. I haven't touched it ever since I created it, and it is executing the operations just fine.
Well, something must be different in your Arch device. Anyway, if it is working, all good.
@chrisleekr I've tried it all on Mac Linux and window, it works just once, It didn't work when i use F5 to refresh the page. I think this problem is caused by my network, I have to use a VPN connection to access binanace. But i found sometimes i can't connect to the binance API. Thank you anyway! o(╥﹏╥)o
@leeweenj If you need to use a VPN to access Binance then I'm quite sure that is why that issue happens. The API request might not be going through the VPN and then it raises the error, and the bot can't function properly. @chrisleekr can shed a better light on this since I might be just wrongfully assuming things here, but to me it looks like it.
@leeweenj That is interesting. I guess you will need to have a separated server like DigitalOcean. I have seen people using that service to run the bot.
Please close the issue if your question is resolved.
Hi guys, i can't access on bot frontend because is always error: binance-api/37 on 19be10351a32: Something wrong with trailing-trade-common cache (version=0.0.65, server=websocket, e={}).
Thanks