title: How to Connect Meteor Server to External Websocket / Socket IO API?
body: <p>In my Meteor 1.0 app, I'm trying to connect the server to an external websocket (socket-io) API provided by a company called BTC China. Details on the API can be found <a href="http://btcchina.org/websocket-api-market-data-documentation-en#javascript" rel="nofollow">here</a>.</p>
  
  <p>All the examples I have found are for the client. How does one subscribe to a socket-io API on the Meteor server? There doesn't seem to be a meteor package for this on <code>atmospherejs.com</code> and I'm struggling a bit. I've installed the <code>socket-io</code> NPM package and gotten this far:</p>
  
  <pre><code>var socket = Npm.require('socket.io').listen('https://websocket.btcchina.com/');
  socket.emit('subscribe', ['marketdata_cnybtc']);
  socket.emit('subscribe', ['marketdata_cnyltc']);
  socket.emit('subscribe', ['marketdata_btcltc']);
  socket.on('connect', function(){
      console.log("Hello,btcc!");
        socket.on('trade', function (data) {
          console.log("Hello,trade!");
            console.log(data);});
  });
  </code></pre>
  
  <p>But this returns the following error: <code>TypeError: Object https://websocket.btcchina.com/ has no method 'listeners'</code>, which means I'm defining the <code>socket</code> variable incorrectly. How can I fix this? Thanks!</p>