Post
Topic
Board Marketplace
Re: [BETA] MTGox websocket API, testers wanted
by
Floomi
on 09/07/2013, 21:05:35 UTC
Folks,

I've been reading this thread with interest as I too am writing a client in Python (using websocket-client). I'm connecting over plain old websockets (not socketio) and am mostly working apart from a couple of issues:

1. Once the connection is established I subscribe to the USD trades channel:
Code:
TRADES = "dbf1dee9-4f2e-4a08-8cb7-748919a71b21"
def subscribe( channel ):
output = { 'op': 'mtgox.subscribe', 'channel': channel }
return json.dumps( output )

ws.send(subscribe(TRADES))
...but I get the remark spat back "Unknown channel requested or not a public channel". I seem to be subscribed to trades by default, so this isn't a huge problem - but is there anything I'm doing wrong here?

2. My websocket connection keeps dropping, for no reason that I can see. This thread's history has some talk about having to send heartbeat messages, but from what I understand that's only when you're connected to socket.io, not the plain old websockets I keep on using. I find all clients I run drop at the same time, regardless of when I start them, which makes me suspect the problem is on Gox's end. I can easily reconnect to it when it drops, but it's frustrating because it takes about 90s between the connection being dropped and me getting a new trade message after I've reconnected. EDIT: I discovered a settimeout(5) sitting quietly in the code, which was likely wrecking things... removing it and upgrading websocket-client to 0.11 seems to have done the trick.

Any advice would be much appreciated!
-Floomi