# Market data subscription

**URL:** <https://community.tradovate.com/t/market-data-subscription/10313>\
**Category:** API Developers\
**Created:** [September 30, 2024, 5:23am UTC](https://community.tradovate.com/t/market-data-subscription/10313 "2024-09-30T05:23:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_Clark](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@Dylan\_Clark](https://community.tradovate.com/u/Dylan_Clark)\
**Post date:** [September 30, 2024, 5:23am UTC](https://community.tradovate.com/t/market-data-subscription/10313/1 "2024-09-30T05:23:26Z")

</div>

Hi,

I have a websocket client that I use for all my exchange market data. It is a c++ client based on websocketscpp. 'after the initial connection is established I am sending the following JSON over websocket connection, where id is always unique (uuid), Im suspecting one of two things.

1. There is a problem with my mis/non use of access token

**OR**

1. The JSON subscription message below is wrong.

“id”:“45646546”, symbol”:“GOOG”}

#[live.tradovateapi.com](http://live.tradovateapi.com/) for Live only functionality.  
#[demo.tradovateapi.com](http://demo.tradovateapi.com/) for simulation engine.  
#[md.tradovateapi.com](http://md.tradovateapi.com/) and for a market data feed.

are available. I am only paper trading (in DEV) so Im connecting to [demo.tradovateapi.com](http://demo.tradovateapi.com/)

• I can successfully issue my request for token using username, secret , cid etc. This is done via a CURL using a C++ request and the response gives me an accessToken, marketAccessToke as well as these other JSON fields

,“hasLive”:false,“outdatedTaC”:false,“hasFunded”:false,“hasMarketData”:true,“outdatedSentimentPolicy”:true}

• Then I can successfully establish a connection to wss://demo.tradovateapi.com/v1/websocket

$ ./client wss://demo.tradovateapi.com/v1/websocket/md/subscribeQuote

**Successfully connected to:**  
**wss://demo.tradovateapi.com/v1/websocket/md/subscribeQuote**  
Running websocket: wss://demo.tradovateapi.com/v1/websocket/md/subscribeQuote  
[2024-09-29 19:17:09] [connect] Successful connection  
[2024-09-29 19:17:09] [connect] WebSocket Connection 34.117.68.229:443 v-2 “WebSocket++/0.8.2” /v1/websocket/md/subscribeQuote 101

Note: I do not use the accessToken or mdAccessToken to connect. I think this is the source of error but I’m not sure.

However I know the wss connection is ok because I get a response back;

Connection is opened ok as my CURL callback receives o” . Note after this I get nothing back, no heartbeats, no “server disconnecting session” etc. (i.e. I get no ‘h’, ‘a’ or ‘c’ messages back from tradovate)

• I then try to subscribe to GOOG with websockets (websocketscpp). I send the follow over the websocket connection opened above (same client process that obtained the tokens)

**{“id”:“0231242342232”,“method”:“subscribe”,“symbol”:“GOOG”}**

I also try with just symbol and id (always uuid)  
{“id”:“45646546”, symbol”:“GOOG”}  
However I cannot subscribe! Nothing is coming back I know today is Sunday and market is closed but this is consistently failing. Can you see the fault?

./client wss://md.tradovateapi.com/v1/websocket/md/subscribeQuote  
g++ -I. -I/home/gjw/websocketpp -std=c++2a -o client websockets.cpp main.cpp -lssl -lcrypto -lcurl -ljsoncpp -lpthread -lwebsockets  
gjw@LUNA056:~/tradovate\_abundance/GRAHAMS$ ./client wss://demo.tradovateapi.com/v1/websocket/md/SubscribeQuote  
Received:  
**{“accessToken”:“XXXXXXXXXXXXXXXXXXXXXXXXX”,“mdAccessToken”:“YYYYYYYYYYYYYYY”,“expirationTime”:“2024-09-29T18:31:05.785Z”,“userStatus”:“Active”,“userId”:2854187,“name”:“Google:102927092604715150178”,“hasLive”:false,“outdatedTaC”:false,“hasFunded”:false,“hasMarketData”:true,“outdatedSentimentPolicy”:true}**

Running websocket: wss://demo.tradovateapi.com/v1/websocket/md/subscribeQuote  
[2024-09-29 19:17:09] [connect] Successful connection  
[2024-09-29 19:17:09] [connect] WebSocket Connection 34.117.68.229:443 v-2 “WebSocket++/0.8.2” /v1/websocket/md/subscribeQuote 101

**Received: o**  
--------------------------\> GREAT - got control character ‘o’ back from tradovate

Sending following subscription symbol message: {“id”:“023991242342232”,“symbol”:“GOOG”}  
Sent OK!  
[2024-09-29 19:17:12] [frame\_header] Dispatching write containing 1 message(s) containing 6 header bytes and 40 payload bytes  
[2024-09-29 19:17:12] [frame\_header] Header Bytes:  
[0] (6) 81 A8 29 2D BC B2

[2024-09-29 19:17:12] [frame\_payload] Payload Bytes:  
[0] (40) [1] R  
¬ ¬  
^KBА fj

[2024-09-29 19:17:13] [control] Control frame received with opcode 8  
[2024-09-29 19:17:13] [frame\_header] Dispatching write containing 1 message(s) containing 6 header bytes and 5 payload bytes  
[2024-09-29 19:17:13] [frame\_header] Header Bytes:  
[0] (6) 88 85 63 61 15 65

[2024-09-29 19:17:13] [frame\_payload] Payload Bytes:  
[0] (5) [8] 60 89 57 1C 06

[2024-09-29 19:17:13] [info] asio async\_read\_at\_least error: asio.ssl.stream:1 (stream truncated)  
[2024-09-29 19:17:13] [error] handle\_read\_frame error: websocketpp.transport:2 (Underlying Transport Error)  
[2024-09-29 19:17:13] [info] asio async\_write error: asio.ssl:337690831 (protocol is shutdown)  
[2024-09-29 19:17:13] [fatal] handle\_write\_frame error: websocketpp.transport:2 (Underlying Transport Error)  
^C
