How to subscribe to the websocket?

Hello all,

I have referred to the following resources:

After I connect to wss://ws-feed.exchange.coinbase.com, I send a subscribe message but it is always rejected by the server.

Example 1:

{
    "type": "subscribe",
    "product_ids": [
        "ETH-USD",
        "ETH-EUR"
    ],
    "channels": [
        "level2",
        "heartbeat",
        {
            "name": "ticker",
            "product_ids": [
                "ETH-BTC",
                "ETH-USD"
            ]
        }
    ]
}
{"type":"error","message":"channel is required"}

Example 2:

{
  "type": "subscribe",
  "channels": [{ "name": "heartbeat", "product_ids": ["ETH-EUR"] }]
}
{"type":"error","message":"channel is required"}

Example 3:

{
  "type": "subscribe",
  "channels": [{ "name": "status"}]
}
{"type":"error","message":"channel is required"}

Basically, I cannot subscribe to any channel.

Question> What did I do wrong here?

Thank you

Hi @q0987, thank you so much for raising this concern. Can you provide more details on this incident (e.g. date and time of occurrence, how and where did you connect to websocket)? This will help our technical teams in investigating the issue faster.

Additionally, for outages and performance degradation issues, you can also log a case on the Contact Us page. The ticket will go directly to our support teams for immediate investigation.

1 Like

Hi @q0987 , we actually tried your code using the Simple WebSocket Client extension in Google Chrome and it seems to be working. The responses that we got from the Websocket are all successful as they are returning continuous heartbeat messages. The issue you are experiencing could be related to your Websocket deployment. We may be able to help you further if you will provide us with the previously requested question which is:

  • Can you provide more details on this incident (e.g. date and time of occurrence, how and where did you connect to Websocket)?

Thanks!

Hello,

I was using Browser WebSocket Client to test the connection with coinbase yesterday without success but now it works without any issues.

Many thanks!

1 Like

Hello @q0987! We are glad to hear that it is now working on your end. Thanks!