Worker error of JSON parsing error

Hello , when I try to createWebRtcServer on worker , it always failed by below error:

mediasoup:Worker createWebRtcServer() +3ms
mediasoup:Channel request() [method:worker.createWebRtcServer, id:1] +5ms
mediasoup:ERROR:Worker (stderr) Channel::ChannelSocket::OnConsumerSocketMessage() | JSON parsing error: [json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - unexpected ':'; expected end of input +0ms

I checked my typescript code , and confirm there is no JSON format error:

        this.webrtcServer = await this.worker.createWebRtcServer({
                port: 5000

This error only occur on ubuntu system. And when I run it on Centos7 or MacOS , it works fine.
Could you help to give me some clue? I’m not sure where am I wrong.

Really thanks for your reply.

No idea about that error, never seen it. But we are migrating JSON to flatbuffers in mediasoup and will be released soon, so this won’t happen again.

But where do you see a JSON here? This is just a JavaScript object. JSON appears only at Channel.request, as a part of the string it writes to the socket, and I doubt nodejs’s JSON.stringify works differently in ubuntu or anywhere else. It is worth to add a console output for the msg argument of the ChannelRequest constructor temporarily (in worker/src/Channel/ChannelRequest.cpp) to investigate.

And such a JSON reaches the worker and the worker parses it in C++ and, for some unknown reason, it is failing to parse it in your scenario, so of course there is JSON involved here.

I’m not gonna investigate JSON parsing errors because, as I said, we are about to remove JSON based communication very soon. Anyway, since you and only you have suffered from that issue, you may replicate it, print the message received by the worker in C++ and diagnose the problem.

I have found the root cause, one of our colleagues specified workerBin to an old version which do not support this createWebRtcServer API , and forgot to clear env variable.

@ibc , @snnz Thank you for support. we should be more careful to use env variable to change workerBin.

That must have been a version prior to the internal message format change, which tried to parse the entire string as JSON object. Hence the obscure kind of error it produced.

No, flatbuffers PR is not merged yet.

I mean that the message text is now id:method:JSON, not just JSON as it was earlier. So, JSON parser successfully scanned a 1-character number (id) and then ran into unexpected ‘:’ in column 2.

True. It could be that.