forked from pabloFuente/mediasoup-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
724 lines (629 loc) · 27.2 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
const SERVER_CONFIG = require('./config');
const MediaSoup = require('mediasoup');
const Express = require('express');
const Fs = require('fs');
const Https = require('https');
const SocketIO = require('socket.io');
const Colors = require('colors/safe');
const Spawn = require('child_process').spawn;
var Kill = require('tree-kill');
expressApp = Express();
expressApp.use(Express.json());
expressApp.use(Express.static(__dirname));
expressApp.use((error, req, res, next) => {
if (error) {
console.warn('Express app error,', error.message);
error.status = error.status || (error.name === 'TypeError' ? 400 : 500);
res.statusMessage = error.message;
res.status(error.status).send(String(error));
} else {
next();
}
});
const tls = {
cert: Fs.readFileSync('./cert/cert.pem'),
key: Fs.readFileSync('./cert/key.pem'),
};
httpsServer = Https.createServer(tls, expressApp);
httpsServer.on('error', (err) => {
console.error('starting HTTPS server failed,', err.message);
});
httpsServer.listen(SERVER_CONFIG.port, SERVER_CONFIG.ip, () => {
console.log('Server is running and listening on https://%s:%s', SERVER_CONFIG.ip, SERVER_CONFIG.port);
// Set internal ip in SDP file
var fs = require('fs');
const sdpPaths = ['./recording/audioVideo.sdp', './recording/onlyAudio.sdp', './recording/onlyVideo.sdp'];
const REGEX = /c=IN IP4 \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/g;
const REPLACEMENT = 'c=IN IP4 ' + SERVER_CONFIG.internalIp;
sdpPaths.forEach(sdpPath => {
fs.readFile(sdpPath, 'utf8', (err, data) => {
if (err) {
return console.log(err);
}
const result = data.replace(REGEX, REPLACEMENT);
fs.writeFile(sdpPath, result, 'utf8', (err) => {
if (err) {
console.error('Error overwriting recording SP file', err);
process.exit(1);
}
});
});
});
});
// A worker represents a mediasoup C++ subprocess that runs in a single CPU core and handles Router instances
let msWorker;
// A router enables injection, selection and forwarding of media streams through Transport instances created on it.
// Developers may think of a mediasoup router as if it were a “multi-party conference room”, although mediasoup is
// much more low level than that and doesn't constrain itself to specific high level use cases (for instance, a
// “multi-party conference room” could involve various mediasoup routers, even in different physicals hosts)
let msRouter;
// A transport connects an endpoint with a mediasoup router and enables transmission of media in both directions by
// means of Producer and Consumer instances created on it. mediasoup implements the following transport classes:
// [WebRtcTransport, PlainRtpTransport, PipeTransport]
let msTransport;
// A producer represents an audio or video source being injected into a mediasoup router. It's created on top of
// a transport that defines how the media packets are carried
let msProducer;
// A consumer represents an audio or video source being forwarded from a mediasoup router to an endpoint. It's
// created on top of a transport that defines how the media packets are carried
let msConsumer;
// Collection of sessions
let sessions = new Map();
// Collection of users (websocket connections)
let finalUsers = new Map();
// Collection of recordings
let recordings = new Map();
const socketServer = SocketIO(httpsServer, {
serveClient: false,
path: SERVER_CONFIG.path,
log: false,
pingInterval: SERVER_CONFIG.ws.pingInterval,
pingTimeout: SERVER_CONFIG.ws.pingTimeout,
transports: ['websocket']
});
socketServer.on('connection', socket => {
console.log('Client connected from %s:%s', socket.request.connection.remoteAddress, socket.request.connection.remotePort);
finalUsers.set(socket.id, {
ws: socket,
producerTransports: new Map(),
consumerTransports: new Map(),
producers: new Map(),
consumers: new Map()
});
console.log(finalUsers.keys());
socket.on('disconnect', reason => {
console.log('WebSocket %s is closed. Reason: %s', socket.id, reason);
removeFinalUser(socket.id);
});
socket.on('error', error => {
console.error('Error on websocket ' + socket.id, error);
});
socket.on('joinRoom', async (data, callback) => {
const sessionId = data.sessionId;
let session = sessions.get(sessionId);
if (!session) {
// New created session
createRouter(msWorker)
.then(router => {
console.log('mediasoup Router initialized for session %s', sessionId);
sessions.set(sessionId, {
router: router,
users: [socket.id]
});
console.log(router.rtpCapabilities);
callback({
rtpCapabilities: router.rtpCapabilities
});
})
.catch(error => {
console.error('Error initializing mediasoup router for session ' + sessionId, error);
});
} else {
// Add user to existing session
const session = sessions.get(sessionId);
session.users.push(socket.id);
callback({
rtpCapabilities: session.router.rtpCapabilities
});
}
});
/**
* Publish stuff
*/
socket.on('createProducerTransport', async (data, callback) => {
const sessionId = data.sessionId;
const sessionRouter = sessions.get(sessionId).router;
createWebRtcTransport(sessionRouter)
.then(transport => {
console.log('mediasoup WebRtcTransport initialized for user %s in session %s (producer)', socket.id, sessionId);
finalUsers.get(socket.id).producerTransports.set(transport.id, transport);
callback({
transportOptions: {
id: transport.id,
iceParameters: transport.iceParameters,
iceCandidates: transport.iceCandidates,
dtlsParameters: transport.dtlsParameters,
sctpParameters: transport.sctpParameters
},
rtpCapabilities: sessionRouter.rtpCapabilities
});
}).catch(error => {
console.error('Error initializing mediasoup WebRtcTransport for user ' + socket.id + ' in session ' + sessionId + '(producer)', error);
})
});
socket.on('connectProducerTransport', async (data, callback) => {
let producerTransport = finalUsers.get(socket.id).producerTransports.get(data.transportId);
producerTransport.connect({
dtlsParameters: data.dtlsParameters
});
callback();
});
socket.on('produce', async (data, callback) => {
let producerTransport = finalUsers.get(socket.id).producerTransports.get(data.transportId);
producerTransport.produce({
kind: data.kind,
rtpParameters: data.rtpParameters
}).then(producer => {
console.log('mediasoup Producer initialized for user %s. {kind: %s, type: %s}', socket.id, producer.kind, producer.type);
finalUsers.get(socket.id).producers.set(producer.id, producer);
producer.on('transportclose', () => {
});
producer.on('score', score => {
});
producer.on('videoorientationchange', videoOrientation => {
});
callback({
id: producer.id
});
// Broadcast new producer
socket.broadcast.emit('newProducer');
}).catch(error => {
console.error('Error producing', error);
})
});
socket.on('pauseProducer', async (data, callback) => {
const producer = finalUsers.get(socket.id).producers.get(data.producerId);
if (!producer.paused) {
producer.pause();
}
callback();
});
socket.on('resumeProducer', async (data, callback) => {
const producer = finalUsers.get(socket.id).producers.get(data.producerId);
if (!producer.paused) {
return;
}
producer.resume();
callback();
});
socket.on('closeProducer', async (data, callback) => {
const producer = finalUsers.get(socket.id).producers.get(data.producerId);
if (producer.closed) {
return;
}
producer.close();
callback();
});
/**
* Subscribe stuff
*/
socket.on('createConsumerTransport', async (data, callback) => {
const sessionId = data.sessionId;
let sessionRouter = sessions.get(sessionId).router;
createWebRtcTransport(sessionRouter)
.then(transport => {
console.log('mediasoup WebRtcTransport initialized for user %s in session %s (consumer)', socket.id, sessionId);
finalUsers.get(socket.id).consumerTransports.set(transport.id, transport);
callback({
transportOptions: {
id: transport.id,
iceParameters: transport.iceParameters,
iceCandidates: transport.iceCandidates,
dtlsParameters: transport.dtlsParameters,
sctpParameters: transport.sctpParameters
},
rtpCapabilities: sessionRouter.rtpCapabilities
});
}).catch(error => {
console.error('Error initializing mediasoup WebRtcTransport for user ' + socket.id + ' in session ' + sessionId + '(consumer)', error);
})
});
socket.on('connectConsumerTransport', async (data, callback) => {
let consumerTransport = finalUsers.get(socket.id).consumerTransports.get(data.transportId);
consumerTransport.connect({
dtlsParameters: data.dtlsParameters
});
callback();
});
socket.on('consume', async (data, callback) => {
const sessionRouter = sessions.get(data.sessionId).router;
const videoProducerId = data.videoProducerId;
const audioProducerId = data.audioProducerId;
if (!sessionRouter.canConsume({
producerId: data.videoProducerId,
rtpCapabilities: data.rtpCapabilities
})) {
console.error('Can NOT consume video');
return;
}
if (!sessionRouter.canConsume({
producerId: data.audioProducerId,
rtpCapabilities: data.rtpCapabilities
})) {
console.error('Can NOT consume audio');
return;
}
let consumerTransport = finalUsers.get(socket.id).consumerTransports.get(data.transportId);
consumerTransport.consume({
producerId: videoProducerId,
rtpCapabilities: data.rtpCapabilities,
paused: false
}).then(videoConsumer => {
console.log('mediasoup VIDEO Consumer initialized for user %s for Producer %s. {kind: %s, type: %s}', socket.id, videoConsumer.producerId, videoConsumer.kind, videoConsumer.type);
finalUsers.get(socket.id).consumers.set(videoConsumer.id, videoConsumer);
consumerTransport.consume({
producerId: audioProducerId,
rtpCapabilities: data.rtpCapabilities,
paused: false
}).then(audioConsumer => {
console.log('mediasoup AUDIO Consumer initialized for user %s for Producer %s. {kind: %s, type: %s}', socket.id, audioConsumer.producerId, audioConsumer.kind, audioConsumer.type);
finalUsers.get(socket.id).consumers.set(audioConsumer.id, audioConsumer);
const response = {
video: {
id: videoConsumer.id,
producerId: videoConsumer.producerId,
kind: videoConsumer.kind,
rtpParameters: videoConsumer.rtpParameters,
type: videoConsumer.type,
paused: videoConsumer.producerPaused,
},
audio: {
id: audioConsumer.id,
producerId: audioConsumer.producerId,
kind: audioConsumer.kind,
rtpParameters: audioConsumer.rtpParameters,
type: audioConsumer.type,
paused: audioConsumer.producerPaused
}
};
if (videoConsumer.type === 'simulcast' || videoConsumer.type === 'svc') {
const scalabilityMode = videoConsumer.rtpParameters.encodings[0].scalabilityMode;
console.log('Scalability mode for video consumer: ' + scalabilityMode);
const {
spatialLayers,
temporalLayers
} = MediaSoup.parseScalabilityMode(scalabilityMode);
const firstSpatialLayer = spatialLayers - 1;
const firstTemporalLayer = temporalLayers - 1;
response['currentLayers'] = {
spatialLayer: firstSpatialLayer,
temporalLayer: firstTemporalLayer
};
videoConsumer.on('layerschange', layers => {
console.log('LAYERS CHANGED', layers);
});
console.log('Setting simulcast video consumer to use spatial layer ' + firstSpatialLayer + ' and temporal layer ' + firstTemporalLayer);
// Max quality
videoConsumer.setPreferredLayers({
spatialLayer: firstSpatialLayer,
temporalLayer: firstTemporalLayer
}).then(() => {
callback(response);
});
} else {
callback(response);
}
}).catch(error => {
console.error('Error consuming audio', error);
});
}).catch(error => {
console.error('Error consuming video', error);
});
});
socket.on('pauseConsumer', async (data, callback, errback) => {
const consumer = finalUsers.get(socket.id).consumers.get(data.consumerId);
if (!consumer.paused) {
consumer.pause();
}
callback();
});
socket.on('resumeConsumer', async (data, callback) => {
const consumer = finalUsers.get(socket.id).consumers.get(data.consumerId);
if (consumer.paused) {
consumer.resume();
}
callback();
});
socket.on('closeConsumer', async (data, callback) => {
const consumer = finalUsers.get(socket.id).consumers.get(data.consumerId);
if (!consumer.closed) {
consumer.close();
}
callback();
});
socket.on('publisherStats', async (data, callback) => {
const producer = finalUsers.get(socket.id).producers.get(data.producerId);
producer.getStats().then(stats => {
callback({
stats,
score: producer.score,
encodings: producer.rtpParameters.encodings,
});
});
});
socket.on('subscriberStats', async (data, callback) => {
const consumer = finalUsers.get(socket.id).consumers.get(data.consumerId);
consumer.getStats().then(stats => {
callback({
stats,
currentLayers: consumer.currentLayers,
encodings: consumer.rtpParameters.encodings,
score: consumer.score
});
});
});
socket.on('changeSimulcast', async (data, callback) => {
const consumer = finalUsers.get(socket.id).consumers.get(data.consumerId);
console.log('Current layers', consumer.currentLayers);
console.log('Preferred layters to ' + data.spatialLayer + ' - ' + data.temporalLayer);
consumer.setPreferredLayers({
spatialLayer: data.spatialLayer,
temporalLayer: data.temporalLayer
}).then(() => {
callback();
})
.catch(error => console.error(error));
});
/**
* Recording stuff
*/
let stopRecordingCallbackFunction;
const stopRecordingCallback = () => {
if (!!stopRecordingCallbackFunction) {
stopRecordingCallbackFunction();
}
}
socket.on('record', async (data, callback) => {
let sdpFile;
let outputFile;
const hasAudio = data.hasAudio;
const hasVideo = data.hasVideo;
const audioProducerId = data.audioProducerId;
const videoProducerId = data.videoProducerId;
if (hasAudio) {
if (hasVideo) {
sdpFile = __dirname + '/recording/audioVideo.sdp';
outputFile = __dirname + '/recording/recording.mp4';
} else {
sdpFile = __dirname + '/recording/onlyAudio.sdp';
outputFile = __dirname + '/recording/recording.mp3';
}
} else if (hasVideo) {
sdpFile = __dirname + '/recording/onlyVideo.sdp';
outputFile = __dirname + '/recording/recording.mp4';
}
const sessionId = data.sessionId;
if (!recordings.get(sessionId)) {
recordings.set(sessionId, {
ffmpegProcess: undefined,
transports: [],
consumers: []
});
}
let ffmpegStarted = false;
let recordingStarted = false;
ffmpegProcess = Spawn('ffmpeg', ['-protocol_whitelist', 'file,udp,rtp', '-i', sdpFile, outputFile], {
detached: true
});
ffmpegProcess.on('exit', (code, signal) => {
console.log('Recording process exited with ' + `code ${code} and signal ${signal}`);
if (!signal) {
console.log('Recording successfully stopped');
} else {
console.error('Error stopping recording');
}
if (!!stopRecordingCallback) {
stopRecordingCallback();
}
});
ffmpegProcess.on('disconnect', () => {
console.log('Recording process disconnect');
});
ffmpegProcess.on('error', error => {
console.log('Recording process error', error);
});
ffmpegProcess.on('close', () => {
console.log('Recording process closed');
});
ffmpegProcess.on('message', () => {
console.log('Recording process message');
});
ffmpegProcess.stderr.on('data', data => {
console.log(data.toString());
if (data.toString().startsWith('ffmpeg version') && !ffmpegStarted) {
ffmpegStarted = true;
const sessionRouter = sessions.get(sessionId).router;
sessionRouter.createPlainRtpTransport(SERVER_CONFIG.mediasoup.plainRtpTransport)
.then(plainRtpTransport => {
recordings.get(sessionId).transports.push(plainRtpTransport);
plainRtpTransport.connect({
ip: SERVER_CONFIG.mediasoup.plainRtpTransport.listenIp.ip,
port: 5678
}).then(() => {
console.log('PlainRtpTransport connected');
if (hasAudio) {
plainRtpTransport.consume({
producerId: audioProducerId,
rtpCapabilities: sessionRouter.rtpCapabilities,
paused: false
}).then(consumer => {
recordings.get(sessionId).consumers.push(consumer);
console.log('PlainRtpTransport consuming AUDIO');
}).catch(error => {
console.error(error);
});
}
if (hasVideo) {
plainRtpTransport.consume({
producerId: videoProducerId,
rtpCapabilities: sessionRouter.rtpCapabilities,
paused: false
}).then(consumer => {
recordings.get(sessionId).consumers.push(consumer);
console.log('PlainRtpTransport consuming VIDEO');
}).catch(error => {
console.error(error);
});
}
}).catch(error => {
console.error(error);
});
})
.catch(error => {
console.log(error)
});
} else if (data.toString().startsWith('frame=') && !recordingStarted) {
recordingStarted = true;
callback();
}
});
recordings.get(sessionId).ffmpegProcess = ffmpegProcess;
});
socket.on('stopRecord', async (data, callback) => {
stopRecordingCallbackFunction = callback;
const recording = recordings.get(data.sessionId);
recording.consumers[0].close();
recording.transports[0].close();
Kill(recording.ffmpegProcess.pid, error => {
if (error) {
console.error('Error stopping ffmpeg process');
} else {
console.error('ffmpeg process successfully stopped');
}
});
});
});
function createWorker() {
return new Promise((resolve, reject) => {
MediaSoup.createWorker({
logLevel: SERVER_CONFIG.mediasoup.worker.logLevel,
logTags: SERVER_CONFIG.mediasoup.worker.logTags,
rtcMinPort: SERVER_CONFIG.mediasoup.worker.rtcMinPort,
rtcMaxPort: SERVER_CONFIG.mediasoup.worker.rtcMaxPort,
}).then(worker => {
resolve(worker);
}).catch(error => {
reject(error);
});
});
}
function createRouter(worker) {
return new Promise((resolve, reject) => {
if (!worker) {
reject(new Error('mediasoup Worker is not initialized'));
}
const mediaCodecs = SERVER_CONFIG.mediasoup.router.mediaCodecs;
worker.createRouter({
mediaCodecs
})
.then(router => {
resolve(router);
}).catch(error => {
reject(error);
});
});
}
function createWebRtcTransport(router) {
return new Promise((resolve, reject) => {
let webrtcConfig = SERVER_CONFIG.mediasoup.webRtcTransport;
webrtcConfig['listenIps'] = [{
ip: SERVER_CONFIG.internalIp,
announcedIp: null
}];
router.createWebRtcTransport(webrtcConfig)
.then(response => {
resolve(response);
}).catch(error => {
reject(error);
});
});
}
function removeFinalUser(userId) {
// Remove from collection of users
finalUsers.delete(userId);
// Remove from any session to which it was connected
sessions.forEach(session => {
var index = session.users.indexOf(userId);
if (index !== -1) {
session.users.splice(index, 1);
}
});
}
createWorker()
.then(worker => {
msWorker = worker;
msWorker.on('died', () => {
console.error('mediasoup Worker died, exiting in 2 seconds... [pid:%d]', worker.pid);
setTimeout(() => process.exit(1), 2000);
});
console.log('mediasoup worker initialized\n');
}).catch(error => {
console.error('Error initializing mediasoup worker');
});
/**
* mediasoup Observer API
*/
MediaSoup.observer.on('newworker', (worker) => {
console.log(Colors.yellow('OBSERVER API: new worker created [worke.pid:%d]'), worker.pid);
worker.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: worker closed [worker.pid:%d]'), worker.pid);
});
worker.observer.on('newrouter', (router) => {
console.log(
Colors.yellow('OBSERVER API: new router created [worker.pid:%d, router.id:%s]'),
worker.pid, router.id);
router.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: router closed [router.id:%s]'), router.id);
});
router.observer.on('newtransport', (transport) => {
console.log(
Colors.yellow('OBSERVER API: new transport created [worker.pid:%d, router.id:%s, transport.id:%s]'),
worker.pid, router.id, transport.id);
transport.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: transport closed [transport.id:%s]'), transport.id);
});
transport.observer.on('newproducer', (producer) => {
console.log(
Colors.yellow('OBSERVER API: new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]'),
worker.pid, router.id, transport.id, producer.id);
producer.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: producer closed [producer.id:%s]'), producer.id);
});
});
transport.observer.on('newconsumer', (consumer) => {
console.log(
Colors.yellow('OBSERVER API: new consumer created [worker.pid:%d, router.id:%s, transport.id:%s, consumer.id:%s]'),
worker.pid, router.id, transport.id, consumer.id);
consumer.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: consumer closed [consumer.id:%s]'), consumer.id);
});
});
transport.observer.on('newdataproducer', (dataProducer) => {
console.log(
Colors.yellow('OBSERVER API: new data producer created [worker.pid:%d, router.id:%s, transport.id:%s, dataProducer.id:%s]'),
worker.pid, router.id, transport.id, dataProducer.id);
dataProducer.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: data producer closed [dataProducer.id:%s]'), dataProducer.id);
});
});
transport.observer.on('newdataconsumer', (dataConsumer) => {
console.log(
Colors.yellow('OBSERVER API: new data consumer created [worker.pid:%d, router.id:%s, transport.id:%s, dataConsumer.id:%s]'),
worker.pid, router.id, transport.id, dataConsumer.id);
dataConsumer.observer.on('close', () => {
console.log(Colors.yellow('OBSERVER API: data consumer closed [dataConsumer.id:%s]'), dataConsumer.id);
});
});
});
});
});