How to properly cancel response on websockets

Hi Guys. I’m developing in c++ at IOT esp32 device and got successfully websockets connections and conversions in and out the server, using vad. My problem is when sending response.cancel , the server do not accept it and continue to producing audios chunck for me. I’m sending with the correct id and most of the time i receive an error “response_cancel_not_active”.

Can someone help to step by step process to cancel ?

Thanks.

The response_cancel_not_active error usually means the server does not consider there to be an active response at the moment the cancel event is received.

A few things to double-check before going step-by-step debugging:

  1. Response lifecycle
    Make sure the response you’re trying to cancel has actually entered an active state (e.g. you’ve received a response.created / response.started or equivalent from the server) before sending response.cancel.

  2. Response ID consistency
    Confirm that the response_id used in response.cancel exactly matches the currently active response, and that you’re not accidentally generating a new response between creation and cancellation.

  3. Event ordering over WebSocket
    On embedded systems (ESP32 especially), it’s easy to hit timing or buffering issues. Verify that:

    • events are sent in order
    • there’s no parallel response generation
    • cancel isn’t being sent before the server processes the response start
  4. Single active response assumption
    Many realtime APIs only allow cancelling the current active response. If multiple responses are being created concurrently, cancel may fail with this error.

If you can share the exact event sequence (timestamps + server acknowledgements), it’s usually possible to pinpoint where the state mismatch occurs.