Comments (14)
Hello @nlsdfnbch,
Please check below!
In client._subscribe, the payload dictionary is passed to conn.send as separated parameters.
Unfortunately, candles channel has 'key' in payload field.
This is overlapped with original parameter name 'key' in conn.send method, which is used for api key.
A quick fix for this problem is to change parameter name in conn.send, something like below.
def send(self, key=None, secret=None, list_data=None, auth=False, **kwargs):
->
def send(self, api_key=None, api_secret=None, list_data=None, auth=False, **kwargs):
Hope this helps!
from btfxwss.
Hey @BitbeyHub !
Thanks for contributing! From looking at it, this probably due to a pull request I merged earlier. Good catch!
Unfortunately I'm not near a computer till Sunday - until then a workaround may be to prepend a 't' to the symbol when calling the method.
from btfxwss.
I've checked the logs and found that Bitfinex doesn't like the way I send the subscription for candles:
DEBUG:btfxwss.client:_subscribe: {'key': 'trade:1m:tBTCUSD', 'event': 'subscribe', 'channel': 'candles'}
DEBUG:btfxwss.connection:_on_message(): Received new message {"channel":"candles","event":"error","msg":"key: invalid","code":10300} at 1506424899.4304948
However, according to their documentation, this is what they want:
// request
{
event: "subscribe",
channel: "candles",
key: "trade:1m:tBTCUSD"
}
Which is, as far as I can tell, the same thing as mine. Will look into this further.
from btfxwss.
Sorry I am not very familiar with github and ... I found it might be my network reason after I made the script repeat the line of code again and again only if it's in "KeyError" until it's connected successfully. Or so I can say I ... fixed it ?
And I traced back to its importing modules, only to find that the functions finally need to compare elements with the retrieved Queue object. Given my network unconnected, the Queue object to be compared with must be empty. So being empty means nothing to compare. Hence the KeyError occurred.
And there is another question I wanna cast : which branch is kept latest should I download and install if I wanna conduct websocket connect in Python 3.6.2?
from btfxwss.
@BitbeyHub, the release branch is the currently most up-to-date branch.
from btfxwss.
I have opened a ticket with the Bitfinex Support Team
, hopefully they'll find out what's going on here.
Although I'm quite positive it's something odd on my end, I just haven't been able to spot it.
from btfxwss.
Fixed here: #64.
If you need a quick fix, you can modify your requirements.txt to replace:
btfxwss==1.1.1
with
-e git://github.com/TapWealth/btfxwss.git#egg=btfxwss
from btfxwss.
Note, the fix above also makes the code Python2 compatible which was a requirement for my use case. If you want to avoid any side effects of those changes and just want to fix the KeyError
issue, here's the change that fixes it:
https://github.com/nlsdfnbch/btfxwss/pull/64/files#diff-fa3139a968f240692f4ad7f331d4ff7dR153
from btfxwss.
@kimms213
You're right! Fixed it that way. Thanks for the help and pointers, people!
from btfxwss.
I still have this error. I created a python file for collecting data (candles) of one PAIR. Then I created a bash script for running (with nohup) my python file many times with different pairs.
When I run my bash script with lets say 4-5 pairs - its ok. But if I run it with 10 pairs first 4-5 pairs are running ok but next pairs raises an error like [9]- Exit 1 nohup python3 $COLLECTOR $PAIR > $OUT_COLLECTOR
I think it might be because I create many websocket connection for collecting one pair. Is it true or I should look another cause of this error?
from btfxwss.
That is likely the case, yes - Bitfinex allows a maximum of 4-6 Requests per minute to the Websocket API, if I remember correctly. So You should connect once, and send a channel subscription for each pair on that one connection.
from btfxwss.
@nlsdfnbch Thank you Nils!
I didn't find any limitation of requests for websocket on official website.
Do you know if there is some limit for channel subscription? I mean how many pairs I can subscribe per one ws connection.
from btfxwss.
@Closius, I dug through my mails and found a ticket I had opened with them a few months ago, that's where I got the limit from:
The limit is 15 connections per minute. You should hardly ever need to connect more that once or twice per minute. You should connect and keep the connection open for longer periods. You should only need to connect a few time per day, if at all.
Kind regards,
Bjorn
Bitfinex.com
So It's 15 per minute, but still, that might happen pretty quickly if the client is executed multiple times and tries to reconnect.
You can subscribe to every single channel with all kinds of configurations - I haven't hit a limit for this on a single connection yet (and I run about 50 configurations)
from btfxwss.
@nlsdfnbch Thank you!
from btfxwss.
Related Issues (20)
- Timeout settings? HOT 1
- Websocket configuration is not restored during reconnect HOT 1
- pip install not newest version HOT 1
- after running for hours the timeout become much HOT 1
- Connection Issue HOT 2
- A proper handling of a Bitfinex-initiated connection closing
- how to reconnect properly HOT 3
- ORDER RELATED API HOT 1
- SUBSCRIPTION TO DATA HOT 1
- authenticated channels HOT 4
- New websocket-client release breaking code HOT 1
- client_tests don't work HOT 8
- problems with reconection HOT 3
- Pypi version 1.2.2 breaks `raise_exception` HOT 3
- websockets reconnecting constantly? HOT 2
- the auth_nonce problem
- fail to run client.py ,help HOT 2
- not responding sometimes
- Upcoming Bitfinex API Update June 2019
- Account channel not updated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btfxwss.