I am trying to initiate a call with Dial and start a data stream with Media Streamings so I can use that information later. The problem is that the call goes through, but no message is sent through the websocket and the twilio console gives me this error message Stream - WebSocket - Handshake Error. Im using NestJS and SocketIO. Im connection to the websocket gateway using postman and its working properly.
This what I am doing:
voiceResponse
.start()
.stream({
url: 'wss://XXX-XXXX-XXXX.ngrok-free.app',
});
const dial = voiceResponse.dial({ callerId: from });
dial.number(to);
And this is my WebSockets Gateway
@WebSocketServer() server: SocketIOServer;
private logger: Logger = new Logger('WebSockets Gateway');
afterInit(server: any) {
this.logger.log('WebSocket gateway initialized');
}
handleConnection(client: any, ...args: any[]) {
this.logger.log('Client connected');
}
handleDisconnect(client: any) {
this.logger.log('client disconnected');
}
@SubscribeMessage('start')
handleStreamStart(client: any, payload: any) {
console.log('Streaming started');
}
@SubscribeMessage('media')
handleMediaStream(client: any, payload: any) {
console.log(payload);
}