device.load() throw TypeError

Hi, ibc,

I get the TypeError when I excute device.load(routerRtpCapabilities), that issued on github, https://github.com/versatica/mediasoup-client/issues/120 .

Please help me to fix the issue.

Thank you so much.

//-------------------------------------------------------
on server side:

const worker = await mediasoup.createWorker(
{
logLevel : config.mediasoup.workerSettings.logLevel,
logTags : config.mediasoup.workerSettings.logTags,
rtcMinPort : Number(config.mediasoup.workerSettings.rtcMinPort),
rtcMaxPort : Number(config.mediasoup.workerSettings.rtcMaxPort)
});
const { mediaCodecs } = config.mediasoup.routerOptions;
const rtpCapabilities = mediasoup.getSupportedRtpCapabilities();
console.log(rtpCapabilities);

// Create a mediasoup Router.
const mediasoupRouter = await worker.createRouter({ mediaCodecs });
console.log(mediasoupRouter.rtpCapabilities);
signaling.emit(mediasoupRouter.rtpCapabilities);

//----------------------------------------------------

on client side:

import { Device } from ā€˜mediasoup-clientā€™;
import mySignaling from ā€˜./my-signalingā€™; // Our own signaling stuff.

try {
// Create a device (use browser auto-detection).
const device = new Device();

// Communicate with our server app to retrieve router RTP capabilities.
const routerRtpCapabilities = await mySignaling.request(ā€˜getRouterCapabilitiesā€™);
console.log(routerRtpCapabilities); // see the following log
// Load the device with the router RTP capabilities.
await device.load({ routerRtpCapabilities }); // throw TypeError
}
catch (e) {
console.log(e);
}

Hey,

I find the reason and resolve it, that is my signaling problem.

Thank you.

1 Like

Hey, i just want to know.
What is your signalling error in thisā€¦??
I m also stucked in this but not able to find any docs related to it.

How are you passing routerRtpCapabilities to the device?
Please make sure itā€™s a JSON object.

why must json?i change it to json but not work too.

Have you know that?I am also stucked in that.

I just got the error in my socket.io protocol and just solved itā€¦ thnx btw