Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error using websocket listening to sip feed subscribing only to quotes #273

Open
2 tasks done
markSbrandt opened this issue Oct 25, 2024 · 1 comment
Open
2 tasks done

Comments

@markSbrandt
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm using v3.0.1 and subscribing using quotesWebSocket = alpacaClient.data_stream_v2; with alpacaClient getting initialized with feed: 'sip'.

I subscribe to only quote using : quotesWebSocket.subscribe({ quotes: [symbol] });
After a few quotes I get an error like so:


/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70
        if (trades.length > 0 ||
                   ^

TypeError: Cannot read properties of undefined (reading 'length')
    at AlpacaStocksClient.subscribeAll (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70:20)
    at AlpacaStocksClient.<anonymous> (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:136:22)
    at AlpacaStocksClient.emit (node:events:529:35)
    at AlpacaStocksClient.handleMessage (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:206:26)
    at WebSocket.<anonymous> (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:111:18)
    at WebSocket.emit (node:events:517:28)
    at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1070:20)
    at Receiver.emit (node:events:517:28)
    at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:502:14)
    at Receiver.getData (/app/node_modules/ws/lib/receiver.js:435:17)

Node.js v18.20.4

I'm going to try two diff things later tonight ... quotesWebSocket.subscribeForQuote(symbol) and quotesWebSocket.subscribe({ quotes: [symbol], trades: [] })

Expected Behavior

I expect to get messages for only things i subscribed for and not errors for things i didn't

SDK Version I encountered this issue in

3.0.1

Steps To Reproduce

I'm using `v3.0.1` and subscribing using `quotesWebSocket = alpacaClient.data_stream_v2;` with alpacaClient getting initialized with `feed: 'sip'`.

I subscribe to only quote using : `quotesWebSocket.subscribe({ quotes: [symbol] });`

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

No response

@markSbrandt
Copy link
Author

more context on error ... appears to happen after disconnect / reconnect

info: undefined {"timestamp":"2024-11-13T14:42:56.244Z"}
    "forwards": 0,
    "replies": null,
no pong received from server, terminating...
connection closed with code: 1006 and message: 
    "editDate": null,
    "postAuthor": null,
Reconnecting...
    "groupedId": null,
info: Data Stream WebSocket state changed "waiting to reconnect" {"timestamp":"2024-11-13T14:43:02.626Z"}
info: Data Stream WebSocket state changed "connecting" {"timestamp":"2024-11-13T14:43:02.628Z"}
info: Data Stream WebSocket state changed "authenticating" {"timestamp":"2024-11-13T14:43:02.689Z"}
    "reactions": null,
    "restrictionReason": null,
    "ttlPeriod": null,
info: Data Stream WebSocket state changed "connected" {"timestamp":"2024-11-13T14:43:02.691Z"}
error: Data Stream WebSocket error: "connection limit exceeded" {"timestamp":"2024-11-13T14:43:02.853Z"}
    "quickReplyShortcutId": null,
connection closed with code: 1006 and message: 
Reconnecting...
    "effect": null,
    "factcheck": null,
info: Data Stream WebSocket state changed "waiting to reconnect" {"timestamp":"2024-11-13T14:43:12.034Z"}
    "className": "Message"
info: Data Stream WebSocket state changed "connecting" {"timestamp":"2024-11-13T14:43:12.034Z"}
  },
info: Data Stream WebSocket state changed "authenticating" {"timestamp":"2024-11-13T14:43:12.074Z"}
  "pts": 125935,
info: Data Stream WebSocket state changed "connected" {"timestamp":"2024-11-13T14:43:12.076Z"}
info: Data Stream WebSocket state changed "authenticated" {"timestamp":"2024-11-13T14:43:12.085Z"}
  "ptsCount": 1,
  "className": "UpdateNewChannelMessage"
} {"timestamp":"2024-11-13T14:42:19.802Z"}
/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70
        if (trades.length > 0 ||
                   ^
TypeError: Cannot read properties of undefined (reading 'length')
    at AlpacaStocksClient.subscribeAll (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/stock_websocket_v2.js:70:20)
    at AlpacaStocksClient.<anonymous> (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:136:22)
info: Event: {
    at AlpacaStocksClient.emit (node:events:529:35)
  "message": {
    at AlpacaStocksClient.handleMessage (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:206:26)
    "flags": 17408,
    at WebSocket.<anonymous> (/app/node_modules/@alpacahq/alpaca-trade-api/dist/resources/datav2/websocket.js:111:18)
    "out": false,
    at WebSocket.emit (node:events:517:28)
    "mentioned": false,
    at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:1070:20)
    "mediaUnread": false,
    at Receiver.emit (node:events:517:28)
    "silent": false,
    at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:502:14)
    "post": true,
    at Receiver.getData (/app/node_modules/ws/lib/receiver.js:435:17)
    "fromScheduled": false,
    "legacy": false,
    "editHide": false,
    "pinned": false,
    "noforwards": false,
    "invertMedia": false,
    "flags2": 0,
    "offline": false,
    "id": 115455,
    "fromId": null,
    "fromBoostsApplied": null,
    "peerId": {
      "channelId": <redacted>,
      "className": "PeerChannel"
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant