Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
how to send audio stream between child processes in nodejs

How do i properly send stream to a child process. I am trying to stream audio from client to server using this method

I am getting the audio stream from client


const ss = require('socket.io-stream');
const socketIo = require('socket.io');

server = http.createServer(app);
io = socketIo(server);

const child_process = childProcess.fork('./child_process.js');


io.on('connect', (client) => {


    // when the client sends 'stream-transcribe' events
    // when using audio streaming
    ss(client).on('stream-transcribe', function(stream, data) {
     
    var combine_data = {
            "data": data,
            "stream": stream,
            "event":"new_stream"
          }
    
     child_process.send(combine_data)


  }


}
 

this call

     child_process.send(combine_data)

throws the error

node:internal/child_process/serialization:127 const string = JSONStringify(message) + '\n'; ^

TypeError: Converting circular structure to JSON --> starting at object with constructor 'Namespace' | property 'server' -> object with constructor 'Server' | property 'nsps' -> object with constructor 'Object' --- property '/' closes the circle at stringify () at writeChannelMessage (node:internal/child_process/serialization:127:20) at ChildProcess.target._send (node:internal/child_process:837:17) at ChildProcess.target.send (node:internal/child_process:737:19) at Socket. (/Volumes/GoogleDrive/My Drive/app/server.js:236:40) at Socket.onstream (/Volumes/GoogleDrive/My Drive/app/node_modules/socket.io-stream/lib/socket.js:184:14) at Socket.emit (node:events:526:28) at Socket. (/Volumes/GoogleDrive/My Drive/app/node_modules/component-bind/index.js:21:15) at Socket.emit (node:events:526:28) at /Volumes/GoogleDrive/My Drive/app/node_modules/socket.io/lib/socket.js:528:12

Node.js v17.5.0

what is causing the error and how can I send the stream to child_process ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Any data you send using child_process.send() will be converted to a string using JSON.stringify(). The data you try to send is too complex to be converted to a string. In particular, it uses circular references. You can easily verify this using console.log() or a debugger.

You can try to send only data that can be converted to a string. You probably should not try to send stream at all and only send the relevant fields of data.

Otherwise, you can probably pipe() the stream to stdin of the child process.

Based on the documentation:

ss(client).on('stream-transcribe', function(stream, data) {
  stream.pipe(child_process.stdin);
});

In the child process you can read the data from stdout, which is a readable stream.

child_process.stdout.on('data', (chunk) => {
  // do something with `chunk`
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda