Websocket empty after handoff
# support
d
Hello, I'm using listenUrl in realtime to process the audio, and I've run into an issue that after using the handoff tool to transfer to other agent on vapi the websocket connection stays up but did not receive any data after that, and closes when the call end, with this gap without audio data received. Did anyone go through the same, know issue or solutions? Thanks!
v
This is a known issue: after a handoff, the original
listenUrl
WebSocket may stop streaming audio. The recommended approach is to monitor for a handoff event and then re-establish your WebSocket connection. For example:
Copy code
javascript
socket.onmessage = (event) => {
  if (!(event.data instanceof Blob)) {
    try {
      const message = JSON.parse(event.data);
      if (message.type === 'handoff-completed') {
        reconnectToListenUrl(); // Your logic to reconnect
      }
    } catch (error) {
      console.error('Failed to parse message:', error);
    }
  }
};
Reconnect to the new listenUrl after detecting the handoff to resume audio processing. Source: - [Vapi documentation and known issue explanation](https://docs.vapi.ai/calls/call-features)
c
Hi Diogo Azevedo, If you need help with implementing WebSocket transport for real-time audio communication, you can refer to the [WebSocket Transport documentation](https://docs.vapi.ai/calls/websocket-transport). This guide includes steps to initiate a WebSocket call, audio format configurations, and how to send and receive audio data. For any issues with webhook responses, including empty bodies or specific error codes such as 422, please check your webhook implementation against our [Client Message API documentation](https://docs.vapi.ai/api-reference/webhooks/client-message). This includes setup procedures and configurable messages that should be received during calls. Feel free to ask if you need further details or assistance.