Pages:
Author

Topic: [BETA] MTGox websocket API, testers wanted - page 14. (Read 77681 times)

donator
Activity: 2772
Merit: 1019
"direct connection" to old websocket url is deprecated. you should now use socket.io to get an ID which will be part of a websocket url you can use.
So you see the new "indirect connection" working reliably?


no, not reliable since roughly a week, lots of outages on the websocket part, pretty stable many weeks before that. havent seen the socket.io part fail yet.
legendary
Activity: 2053
Merit: 1356
aka tonikt
"direct connection" to old websocket url is deprecated. you should now use socket.io to get an ID which will be part of a websocket url you can use.
So you see the new "indirect connection" working reliably?
donator
Activity: 2772
Merit: 1019
..I try to get a simple python client running for days now. When I finally managed to connect via websockets, the first thing I read was "deprecated, use socket.io instead".
Even though it's "deprecated" it's still much more reliable than the socket.io interface.
So please don't turn it off!

The only problem is that it doesn't work with the latest Chrome and other late WebSocket libs... and nobody wants to fix it. Sad
That's probably why they labeled it "deprecated".

"direct connection" to old websocket url is deprecated. you should now use socket.io to get an ID which will be part of a websocket url you can use.

check out sample implementation: https://bitcointalksearch.org/topic/m.629600
donator
Activity: 2772
Merit: 1019
..I try to get a simple python client running for days now. When I finally managed to connect via websockets, the first thing I read was "deprecated, use socket.io instead".

Instead of using socket.io (which I cant get to work) I could as well just connect to the underlying websocket just as before, not? I will not have fallback to longpoll etc in case the websocket dies and the socket.io still works. But besides that, my ticker should happily work with just websockets for the future, not?

Is there a new websocket daemon running now, for socket.io, with a different adress?

TL;DR:
Will ws://websocket.mtgox.com/mtgox continue to work?


Ente

the way it works: you connect to socket.io server and it will give you a unique ID which will be part of the url you can subsequently use to connect to websocket. socket.io is just a "negotiation protocol".

look at my python code here: https://bitcointalksearch.org/topic/m.629600
legendary
Activity: 2053
Merit: 1356
aka tonikt
..I try to get a simple python client running for days now. When I finally managed to connect via websockets, the first thing I read was "deprecated, use socket.io instead".
Even though it's "deprecated" it's still much more reliable than the socket.io interface.
So please don't turn it off!

The only problem is that it doesn't work with the latest Chrome and other late WebSocket libs... and nobody wants to fix it. Sad
That's probably why they labeled it "deprecated".
legendary
Activity: 2126
Merit: 1001
..I try to get a simple python client running for days now. When I finally managed to connect via websockets, the first thing I read was "deprecated, use socket.io instead".

Instead of using socket.io (which I cant get to work) I could as well just connect to the underlying websocket just as before, not? I will not have fallback to longpoll etc in case the websocket dies and the socket.io still works. But besides that, my ticker should happily work with just websockets for the future, not?

Is there a new websocket daemon running now, for socket.io, with a different adress?

TL;DR:
Will ws://websocket.mtgox.com/mtgox continue to work?


Ente
newbie
Activity: 23
Merit: 0
December 11, 2011, 12:33:59 PM
I created project for .NET socket.io + WebSockets at codeplex.com
http://socketiowebsockets.codeplex.com/
for now it can hold ssl-connection with mtgox (no parsing json and etc)

my old ideas (in this topic) died and raised again Smiley
full member
Activity: 184
Merit: 100
Feel the coffee, be the coffee.
November 24, 2011, 12:03:43 PM
Quote
   S.ws.send('1::/mtgox')

almost didn't post, but so many complained so I did... instant karma Wink

1JX3YkScnu2RBHjUBZTLB6qBgmGeUWxANL

EDIT: slush, are you coming to Prague? I'm there on saturday and maybe sunday, maybe I recognize you Wink

+1 BTC, Thanks !
donator
Activity: 2772
Merit: 1019
November 24, 2011, 10:41:29 AM
No, I'm not coming to Prague...
(...dramatic drums...)
...because I already am in Prague!.

Would be nice to meet you, however I'm myself curious how I'll be able to communicate with my "fluent" english :-).

Nice. Hoping to meet you. Thanks for the generous token of appreciation you sent me Wink
legendary
Activity: 1386
Merit: 1097
November 24, 2011, 10:35:47 AM
No, I'm not coming to Prague...
(...dramatic drums...)
...because I already am in Prague!.

Would be nice to meet you, however I'm myself curious how I'll be able to communicate with my "fluent" english :-).
donator
Activity: 2772
Merit: 1019
November 24, 2011, 10:07:21 AM
Quote
   S.ws.send('1::/mtgox')

*headdesk*
* slush bashing all developers writing incomplete documentations and expecting that some things are so obvious they don't need to be in doc.

molecular, you're my savior. What's your donation address?

cool to have been of help, especiall to you, slush.

almost didn't post, but so many complained so I did... instant karma Wink

1JX3YkScnu2RBHjUBZTLB6qBgmGeUWxANL

EDIT: slush, are you coming to Prague? I'm there on saturday and maybe sunday, maybe I recognize you Wink
legendary
Activity: 1386
Merit: 1097
November 24, 2011, 10:04:42 AM
Quote
    S.ws.send('1::/mtgox')

*headdesk*
* slush bashing all developers writing incomplete documentations and expecting that some things are so obvious they don't need to be in doc.

molecular, you're my savior. What's your donation address?
donator
Activity: 2772
Merit: 1019
November 24, 2011, 09:58:37 AM
Same status here, lack of any documentation is pretty irritating.

magicaltux has some php sample code that was helpfull for me to code socket.io handshake in python.

(it's still got some debugging output and heartbeat lost detection is not implemented, so on connection drop it doesn't auto-reconnect). oh, and it only does websocket, no other transport.

Quote from: socketio.py
from threading import *
import urllib2, urllib
import simplejson as json
import ssl, socket
import time
from websocket import WebSocket


class SocketIO:
  def __init__(S, url, callback):
    S.url = url
    S.callback = callback
    
  def connect(S):
    data = urllib.urlencode({})
    req = urllib2.Request('https://' + S.url + "/1", data)
    response = urllib2.urlopen(req)
    r = response.read().split(':')
    S.heartbeat_interval = int(r[1])
    print 'heartbeat: ', S.heartbeat_interval
    if 'websocket' in r[3].split(','):
      print "good: transport 'websocket' supported by socket.io server ", S.url
      S.id = r[0]
      print "id: ", S.id

    S.thread = Thread(target = S.thread_func)
    S.thread.setDaemon(True)
    S.thread.start()

  def stop(S):
    S.run = False
    S.thread.join(timeout=1)
    S.keepalive_thread.join(timeout=1)


  def thread_func(S):
    print 'SocketIO: websocket thread started'
    
    my_url = 'wss://' + S.url + "/1/websocket/" + S.id
    
    S.ws = WebSocket(my_url, version=0)
    S.run = True
    S.ws.send('1::/mtgox')

    # start keepalive thread
    S.keepalive_thread = Thread(target = S.keepalive_func)
    S.keepalive_thread.setDaemon(True)
    S.keepalive_thread.start()
    
    msg = S.ws.recv()
    while msg is not None and S.run:
      #print 'SocketIO msg: ', msg
      if msg[:10] == "4::/mtgox:":
        S.callback(msg[10:])
      #elif msg[:3] == "2::":
      #  True
      #else:
      #  print "SocketIO: dont know how to handle msg: ", msg
      msg = S.ws.recv()
      
  def keepalive_func(S):
    while S.run:
      time.sleep(S.heartbeat_interval)
      S.ws.send('2::');
      
def test_callback(msg):
  print 'msg: ', msg

# testcase
if True:
  sio = SocketIO('socketio.mtgox.com/socket.io', test_callback)
  sio.connect()
  time.sleep(100)


I got that websocket implementation from giel (on irc) ("from websocket import WebSocket"), here it is (put in file websocket/__init__.py):

  http://pastebin.com/jrxachSF

You can start using

  #> python socketio.py

it should dump the messages to stdout
legendary
Activity: 1386
Merit: 1097
November 23, 2011, 06:02:13 PM
Same status here, lack of any documentation is pretty irritating.
full member
Activity: 184
Merit: 100
Feel the coffee, be the coffee.
November 23, 2011, 05:55:13 PM
Could someone comment on the following points ?

  • Is the stream API service currently in a usable state ? (I cannot determine this since I cannot subscribe to any channel).
  • What is the proper way to subscribe to a channel ?

Given answers to this, I would be willing to update the wiki with the up-to-date information to clear up the usage of this API.

Heck, i'll give 1 BTC to whomever can enable me to stream prices directly from Mt. Gox with this API.
full member
Activity: 184
Merit: 100
Feel the coffee, be the coffee.
November 23, 2011, 10:36:28 AM
With the URL above, I get a weird reply from the server "7:::1+0", using the supposed official URL, wss://socketio.mtgox.com/mtgox, the server just closes the connection after the SSL handshake.

Very weird.

Yes, you received socket.io handshake response, it's fine. socket.io != websocket.

Quote
Edit: I just figured out that using a WebSockets library is not enough, I have just figured out that socket.io was a whole other layer on top of WebSockets.

Does it work for you? I dropped idea of get it working after playing with it for hours. Lacking documentation, multiple versions of specifications, total mess.

Then I implemented bitcoincharts socket interface in 15 minutes...

I can now connect fine, but I cannot subscribe to any channel, I get "invalid request" or "invalid command", so I cannot do anything useful yet. I'm gonna try interfacing bitcoincharts tonight.
legendary
Activity: 1386
Merit: 1097
November 23, 2011, 10:17:15 AM
With the URL above, I get a weird reply from the server "7:::1+0", using the supposed official URL, wss://socketio.mtgox.com/mtgox, the server just closes the connection after the SSL handshake.

Very weird.

Yes, you received socket.io handshake response, it's fine. socket.io != websocket.

Quote
Edit: I just figured out that using a WebSockets library is not enough, I have just figured out that socket.io was a whole other layer on top of WebSockets.

Does it work for you? I dropped idea of get it working after playing with it for hours. Lacking documentation, multiple versions of specifications, total mess.

Then I implemented bitcoincharts socket interface in 15 minutes...
full member
Activity: 184
Merit: 100
Feel the coffee, be the coffee.
November 22, 2011, 11:37:50 PM
Thanks for info. Is following websocket URL correct?

ws://socketio.mtgox.com:80/socket.io/1/websocket/1290678412169625062

I did succeed implementing mtgox socket.io client in my trading client. I used the websocket implementation I used before, coded the handshake.

I remember one time where the socket.io would work, websocket would even connect, but no data being delivered. Maybe this problem just reappeared.

It's working as expected for me now.


With the URL above, I get a weird reply from the server "7:::1+0", using the supposed official URL, wss://socketio.mtgox.com/mtgox, the server just closes the connection after the SSL handshake.

Very weird.

Edit: I just figured out that using a WebSockets library is not enough, I have just figured out that socket.io was a whole other layer on top of WebSockets.
legendary
Activity: 1386
Merit: 1097
November 19, 2011, 08:07:25 PM
Thanks for info. Is following websocket URL correct?

ws://socketio.mtgox.com:80/socket.io/1/websocket/1290678412169625062

I did succeed implementing mtgox socket.io client in my trading client. I used the websocket implementation I used before, coded the handshake.

I remember one time where the socket.io would work, websocket would even connect, but no data being delivered. Maybe this problem just reappeared.

It's working as expected for me now.

donator
Activity: 2772
Merit: 1019
November 19, 2011, 07:52:37 PM
Anyone succeed with new MtGox's socket.io interface? I was succesfull with socket.io handshake, server returned "12906784121696250629:15:25:websocket,flashsocket,htmlfile,xhr-polling,jsonp-polling". But then I open WS connection to ws://socketio.mtgox.com:80/mtgox/socket.io/1/websocket/12906784121696250629 and nothing happen, client don't receive any data. Am I doing anything wrong?

I did succeed implementing mtgox socket.io client in my trading client. I used the websocket implementation I used before, coded the handshake.

I remember one time where the socket.io would work, websocket would even connect, but no data being delivered. Maybe this problem just reappeared.

It's working as expected for me now.
Pages:
Jump to: