My first problem is from
https://bitcointalksearch.org/topic/m.749200:
I try to connect to MtGox via socket.io. I get the connection-id fine, and am able to connect to the websocket too. I then receive heartbeats, which I answer, and continue to receive.
I receive no other data. Things I send have no effect. Just heartbeats, nothing else.
This code is heavily stripped. The full script worked some weeks ago, using these lines.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from websocket import create_connection
import urllib
import re
import time
try:
import json
except ImportError:
import simplejson as json
wsurl = "wss://socketio.mtgox.com/socket.io/"
iourl = "https://socketio.mtgox.com/socket.io/"
############
print "Connecting to socket.io.."
url = iourl + "1"
f = urllib.urlopen(url)
output = f.read()
f.close()
ausgabe = re.search('[0-9]+', output, 0)
sessionid = ausgabe.group()
print "New websocket url:"
wssurl = wsurl + "1" + "/websocket/" + sessionid
print wssurl
############
print "Connecting to websocket..\n"
socket = create_connection(wssurl)
while 1:
echo = socket.recv()
if "1::" in echo:
print "Heartbeat 1"
socket.send("1::")
elif "2::" in echo:
print "Heartbeat 2"
socket.send("2::")
else:
print "Message: ",echo
time.sleep(2)
The websocket client I use here is from
http://pypi.python.org/pypi/websocket-client/0.4.
The whole script dies eventually, from having stripped all error-handling.
If you like to see the whole script, let me know.
I pledge 1 Bitcoin to the first answer to solve this problem.
You are welcome to use PMs or post right here.
Ente
edit: typo which sent '1::' in both types of heartbeats.