Javascript Socket.IO Help Requested

Using Javascript, I’m able to successfully query Alpaca Market Data from ‘’ with fetch(). I’m now trying to implement websocket streaming using Socket.IO, but I keep getting 404 errors with whatever I try.

The code I’m using:

var url = 'wss://';

var params = {
  'action': 'authenticate',
  'data': {
    'key_id': ALPACA_API_KEY_ID,
    'secret_key': ALPACA_API_SECRET_KEY

For the actual connection event I’ve tried all of the following, because I’m not entirely sure how I’m supposed to be passing the handshake data. Each of the following returns a 404 error:

var socket = io(url);
var socket = io(url, { query: params });
var socket = io(url, { query: JSON.stringify(params) });

I’ve tried a number of other tweaks to various things in an attempt to get it to work, but every response I get is a 404. Any help on troubleshooting this is appreciated. I know there’s an Alpaca JS library that could be used, but I’d like to get this working without that, if possible.


This can be disregarded/closed. I ended up being able to successfully connect using the standard WebSocket protocol:

var socket = new WebSocket(‘wss://’);

I’m still not sure why Socket.IO doesn’t work, because I’ve used it in the past without any issues, but I’m glad I have a solution at least.