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 ?
from how to send audio stream between child processes in nodejs
No comments:
Post a Comment