User update socket gives too many messages?

Hi All,

I’m running into the following issue where the “user” channel is giving me more information than what I expect to receive.
The following sequence is what I’ve run to reproduce the ‘issue’ that I’m having. I can handle the below mentioned information in code, but is that really correct?

  1. Open a new order
  2. Cancel the newly created order

What I expect to receive is 1 message when I open the order and 1 message that I’ve cancelled the order.

But what I receive is the following:

Open:
OnMessageReceived({"channel":"user","client_id":"","timestamp":"2024-01-29T17:40:21.836257473Z","sequence_num":139,"events":[{"type":"update","orders":[{"order_id":"THIS-IS-A-FAKE-ID-0001","client_order_id":"THIS-IS-A-FAKE-CLIENTID-0001","cumulative_quantity":"0","leaves_quantity":"181090","avg_price":"0","total_fees":"0","status":"PENDING","product_id":"BONK-USDC","creation_time":"2024-01-29T17:40:21.668876Z","order_side":"BUY","order_type":"Limit","cancel_reason":"","reject_Reason":""}]}]})
OnMessageReceived({"channel":"user","client_id":"","timestamp":"2024-01-29T17:40:21.836287192Z","sequence_num":140,"events":[{"type":"update","orders":[{"order_id":"THIS-IS-A-FAKE-ID-0001","client_order_id":"THIS-IS-A-FAKE-CLIENTID-0001","cumulative_quantity":"0","leaves_quantity":"181090","avg_price":"0","total_fees":"0","status":"OPEN","product_id":"BONK-USDC","creation_time":"2024-01-29T17:40:21.668876Z","order_side":"BUY","order_type":"Limit","cancel_reason":"","reject_Reason":""}]}]})
Cancel:
OnMessageReceived({"channel":"user","client_id":"","timestamp":"2024-01-29T17:40:31.335159121Z","sequence_num":141,"events":[{"type":"update","orders":[{"order_id":"THIS-IS-A-FAKE-ID-0001","client_order_id":"THIS-IS-A-FAKE-CLIENTID-0001","cumulative_quantity":"0","leaves_quantity":"181090","avg_price":"0","total_fees":"0","status":"OPEN","product_id":"BONK-USDC","creation_time":"2024-01-29T17:40:21.668876Z","order_side":"BUY","order_type":"Limit","cancel_reason":"","reject_Reason":""}]}]})
OnMessageReceived({"channel":"user","client_id":"","timestamp":"2024-01-29T17:40:31.584417714Z","sequence_num":142,"events":[{"type":"update","orders":[{"order_id":"THIS-IS-A-FAKE-ID-0001","client_order_id":"THIS-IS-A-FAKE-CLIENTID-0001","cumulative_quantity":"0","leaves_quantity":"181090","avg_price":"0","total_fees":"0","status":"CANCELLED","product_id":"BONK-USDC","creation_time":"2024-01-29T17:40:21.668876Z","order_side":"BUY","order_type":"Limit","cancel_reason":"","reject_Reason":""}]}]})

As you can see I’m receiving 4 messages in total, 2 messages for when I open the order. First a PENDING message and afterwards an OPEN message.
Upon cancellation I receive another 2, first an OPEN order (why?) and then a CANCELLED order.

Why is the first message upon cancellation an OPEN order, shouldn’t this also be a PENDING order to indicate I’m executing an action which is still pending?
Why is it returning me the status of the order which I have already received previously? This causes some headaches for me as I have no way of filtering this status message unless doing a check if the order has already been processed.
This seems to be inaccurate and I’m wondering how other people are handling this if not in the same manner which seems rather sloppy…

@Coinbase, is this really how you intended this websocket to work?

Hi @Okrah

The user channel sends updates on all of a user’s open orders, including all subsequent updates of those orders.

The user channel is intended to work this way, please read here for more information on how user channel works: Advanced Trade WebSocket Channels | Coinbase Cloud

1 Like

Hi @Caleb, thanks for the fast response.

I understand the initial snapshot message. That I parse accordingly. But subsequent API calls to cancel an order return 2 messages on the socket channel. All the other websockets by other exchanges don’t do this. Is there a reason why you send old irrelevant data when we do a new action?

Ok, it took me a while to figure out, but I should’ve been filtering on the ‘Type’. I can skip the message if the type belongs to “snapshot”. Thanks @Caleb for being the rubber ducky :wink: .

1 Like