twilio / media-streams

Quick start guides for configuring and consuming Twilio Media Streams
100 stars 81 forks source link

Twilio Dialogflow Integration error : 'ERR_STREAM_WRITE_AFTER_END' #194

Open rajivcoomarHS opened 2 years ago

rajivcoomarHS commented 2 years ago

After performing the steps given in the readme, when tried to make call, getting below error.

node server.js

Your app is listening on port 3000 Captured call CAe8bda7bf19bf88b6d3f171132fd877a1 Sending audio (44840 characters) node:events:346 throw er; // Unhandled 'error' event ^

Error [ERR_STREAM_WRITE_AFTER_END]: write after end at new NodeError (node:internal/errors:329:5) at ClientHttp2Stream.Writable.write (node:internal/streams/writable:329:11) at /Users/robert/Desktop/dialogflow-integration/node_modules/@grpc/grpc-js/build/src/call-stream.js:416:34 at processTicksAndRejections (node:internal/process/task_queues:94:5) Emitted 'error' event on Http2CallStream instance at: at emitErrorNT (node:internal/streams/destroy:188:8) at emitErrorCloseNT (node:internal/streams/destroy:153:3) at processTicksAndRejections (node:internal/process/task_queues:81:21) { code: 'ERR_STREAM_WRITE_AFTER_END' }

RaheelAshraf commented 1 year ago

I am getting the same issue

komirellipavan commented 1 year ago

@RaheelAshraf @rajivcoomarHS I had the same issue. Some how WebSocket connection is dropping.

In server.js file add code lines in between 2 and 4. It should work

 1. dialogflowService.on("audio", audio => {
 2.  mediaStream = websocketStream(ws, {
 3.     binary: false
 4.  });
RaheelAshraf commented 1 year ago

@komirellipavan I was facing the issue while testing with ngrok. When I deployed the code on the cloud it started working fine