Websocket not sending any messages

Hello,

I have created a websocket and subscribed to Quotes and Bars for 30 symbols.

[
  'PEN', 'CMCSA', 'ADI', 'BKNG',
  'DE', 'AJG', 'ETR', 'BOTZ',
  'WHR', 'EXC', 'ALB', 'CEG',
  'LNT', 'DLTR', 'MSTR', 'CSCO',
  'CHTR', 'RIO', 'AA', 'CARR',
  'LIT', 'EA', 'DOW', 'BK',
  'FDX', 'AMD', 'HPE', 'AIG',
  'ED', 'CBLL'
]

I am using the alpaca.data_stream_v2 from the @alpacahq/alpaca-trade-api.

When I subscribe to the test feed, and subscribe to FAKEPACA quotes and bars everything works as expected and I can see messages coming through in my logs.

When I connect to iex and run locally or on a fly.io server, I can authenticate and subscribe, but I don’t see any event messages coming through (I’ve waited for 24hrs so I don’t think it’s because I’m out of hours)

Is this expected? How can I debug further to determine why I’m not getting quote or bar messages?

Same, websocket not quoting trades past about 12:17 pm Wed Feb 18.

Was working normally, perfectly, from 6:30 am to 12:17 pm.

@rhys_williams @Dave_M There could be several reasons for not seeing quotes or trades from a websocket connection. The most common reason of course is there simply are no quotes or trades. The /iex end point only streams data from the IEX exchange. That exchange is only open from 8:00-17:00 ET so there will not be any data streamed outside of those hours.

The first thing to verify is if there is still an open connection with the Alpaca server. Websockets has some low level calls to verify this, however a good approach is simply to resubscribe to the quotes or trades. In all cases the Alpaca server should respond with something like this:

[{"T":"subscription","trades":["AAPL"],"quotes":["AMD","CLDR"],"bars":["*"],"updatedBars":[],"dailyBars":["VOO"],"statuses":["*"],"lulds":[],"corrections":["AAPL"],"cancelErrors":["AAPL"]}]

If you get that response then you are connected and subscribed to the specified symbols. If not, then for some reason the connection was dropped so simply reconnect. You could actually periodically resubscribe in this fashion as a sort of “heartbeat”.

If you still have issues, reply back with the account number associated with the API key you are using, the symbols you are subscribing to, and an approximate time including time zone when you last subscribed. Ideally, also include the IP address of your client. With that information I can check the Alpaca logs which often provide a bit of detail helpful when troubleshooting.

Thu Feb 19

Websocket was working perfectly all day and any issue no longer exists

A log has been added to socket.onStateChange(state) to capture and print state changes so any future anomolies can be exposed and debugged with more information

Thank you for the timely response

Cheers

@Dave_M Glad to hear your websocket connection is working!