Problems/errors with Kurento Node.JS examples - node.js

I have been trying to write a Node.JS server/client based on the Kurento Media Server, WebRTC conference example. I couldn't get my code to work right, so I thought I would start off by just taking the original example code, setting that up on my dev computer, watching it work, and then slowly making small changes until I got to the way I needed the software to work.
The problem is that I can't get the "webrtc-video-conference-tutorial-kurento" (or the "kurento-one2many-call") example code to work, even if it's completely unmodified. I have tried setting up the current version of Kurento on 2 separate development systems (Ubuntu 18, and Windows 10). Both of them encounter the same errors (code: 40401... Ice Candidate Error).
The exact error text that I am getting is listed below. I would be very greateful for any help you can offer.
Trace: Error: Error adding candidate
at C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-client\lib\KurentoClient.js:361:24
at Object.dispatchCallback [as callback] (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:546:9)
at processResponse (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:667:15)
at RpcBuilder.decode (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:723:5)
at Stream.transportMessage (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:208:10)
at Stream.emit (events.js:315:20)
at Stream.EventEmitter.emit (domain.js:467:12)
at drain (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\through\index.js:36:16)
at Stream.stream.queue.stream.push (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\through\index.js:45:5)
at WebsocketStream.onMessage (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\websocket-stream\index.js:45:15) {
code: 40401,
data: { type: 'ICE_ADD_CANDIDATE_ERROR' }
}
at WebRtcEndpoint.noop (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-client-elements\lib\WebRtcEndpoint.js:35:22)
at callback2 (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\promisecallback\index.js:27:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Message received: candidate
Trace: Error: Error adding candidate
at C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-client\lib\KurentoClient.js:361:24
at Object.dispatchCallback [as callback] (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:546:9)
at processResponse (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:667:15)
at RpcBuilder.decode (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:723:5)
at Stream.transportMessage (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-jsonrpc\lib\index.js:208:10)
at Stream.emit (events.js:315:20)
at Stream.EventEmitter.emit (domain.js:467:12)
at drain (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\through\index.js:36:16)
at Stream.stream.queue.stream.push (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\through\index.js:45:5)
at WebsocketStream.onMessage (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\websocket-stream\index.js:45:15) {
code: 40401,
data: { type: 'ICE_ADD_CANDIDATE_ERROR' }
}
at WebRtcEndpoint.noop (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\kurento-client-elements\lib\WebRtcEndpoint.js:35:22)
at callback2 (C:\Dev\X-Platform\WebDev\webrtc-video-conference-example\src\node_modules\promisecallback\index.js:27:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

Related

client.voice.onVoiceStateUpdate is not a function - DiscordJS

I've been experiencing this issue for a while now; my bot was working perfectly fine about a week ago.
I'm running the latest NodeJS (15.5.1) and Discord.JS (12.5.1) and Erela.js (2.3.1)
I've tried reinstalling all of them with still the return issue (below),
I've asked more than 10 times in the Official Discord.JS server with no avail,
I've asked in the Erela.js Official Discord (awaiting reply)
I'm completely out of ideas as to why I am getting this issue, theres literally nothing with my code as it worked fine, and was running on the latest modules (described above erela.js & discord.js)
Now all of a sudden approx. a week ago now, this issue appeared and I've been trying to troubleshoot it ever since discovering the issue.
I have provided the full stacktrace below along with link to the exact file from discord.js src:
Discord.JS Repo - VoiceStateUpdate.js
[2:57:49 PM] ERROR [Uncaught Exception]: TypeError: client.voice.onVoiceStateUpdate is not a function
at VoiceStateUpdate.handle
(/home/thewarden/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js:31:22)
at Object.module.exports [as VOICE_STATE_UPDATE]
(/home/thewarden/node_modules/discord.js/src/client/websocket/handlers/VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket
(/home/thewarden/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket
(/home/thewarden/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage
(/home/thewarden/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/thewarden/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (node:events:376:20)
at Receiver.receiverOnMessage (/home/thewarden/node_modules/ws/lib/websocket.js:825:20)
at Receiver.emit (node:events:376:20)
at Receiver.dataMessage (/home/thewarden/node_modules/ws/lib/receiver.js:437:14)
at Receiver.getData (/home/thewarden/node_modules/ws/lib/receiver.js:367:17)
at Receiver.startLoop (/home/thewarden/node_modules/ws/lib/receiver.js:143:22)
at Receiver._write (/home/thewarden/node_modules/ws/lib/receiver.js:78:10)
at writeOrBuffer (node:internal/streams/writable:395:12)
at Receiver.Writable.write (node:internal/streams/writable:340:10)
at TLSSocket.socketOnData (/home/thewarden/node_modules/ws/lib/websocket.js:900:35)
voiceStateUpdate is an event. To run it, you'll need to use the client.on()function that calls an event, with the correct callback.
Therefore, your code should look like the following:
client.on('voiceStateUpdate', oldState, newState => {
// code here
})
To learn more about the voiceStateUpdate event and its callback: https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate

Getting error in node js on running application

I am working on a project where I am using angular in frontend and node on the backend. Everything working fine on the local machine. But on production sometimes I am getting the below error on node side and everything stops working.
I have used https://www.npmjs.com/package/sync-request module in my application
uncaughtException: nodeNC failed:
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:35701
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on Socket instance at:
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 35701
}
Error: connect ECONNREFUSED 127.0.0.1:35701 means you may not have started your server and it is not listening to the request
From node.js docs:
ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
This is expected. Since you are making HTTP requests using a synchronous package, which states in the docs:
N.B. You should not be using this in a production application. In a node.js application you will find that you are completely unable to scale your server. In a client application you will find that sync-request causes the app to hang/freeze. Synchronous web requests are the number one cause of browser crashes. For production apps, you should use then-request, which is exactly the same except that it is asynchronous.
I would not personally use a package that has been updated for over two years, when during the same period node.js, JS, and browser technologies have updated their APIs rapidly.
The suggestion I can only give you is to use an asynchronous package, in line with the asynchronous architecture of node, that does that in a non-blocking, event-driven way. Choice is yours but bear in mind that you WILL run into these issues from time to time becasue of these design decisions.
If you need additional help, you need to show your server side code so we can redesign the HTTP handler to be asynchronous and eliminate the ECONNREFUSED error at runtime.
Does this help?

Jasmine test suite doesn't run

I can't figure out what I've done to mess up Jasmine.
Here's a link to the repo I'm working on:
https://github.com/bryanbeus/04-09-bloccit/tree/v0.1.3
The problem is somehow related to the files /spec/integration/flairs_spec.js, /spec/integration/post_spec.js, and probably more.
The problem can be seen when running a command like npm test. I get the following result:
04-09-bloccit#1.0.0 test /home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit
export NODE_ENV=test && jasmine
npm ERR! Test failed. See above for more details.
It used to be that this ERR would only occur if I had an non-compilable error somewhere in my code. (For example, a simple thing like ; out of place, or an improper use of this.)
Recently, I've heard from someone else that this type of failure for Jasmine isn't normal. Usually, if there's a problem in the code, Jasmine is still supposed to say something. ?
Whatever the problem is, it is now spreading to general usage.
I'm trying to call the server npm module for a test with this command:
const server = require("../../src/server");
If that line is anywhere in my files, the entire Jasmine test fails in the exact same manner. (npm ERR... and no other details.)
If I run npm test /spec/integration/flairs_spec.js with that call to server active, the test fails in the npm ERR... manner.
However, if I comment out the call to server, then Jasmine at least runs. It returns this error:
....................
Started
F
Failures:
1) routes : flairs GET /topics/:topicId/posts/:postId/flairs/new should render a new flair form
Message:
Expected Error: connect ECONNREFUSED 127.0.0.1:3000 to be null.
Stack:
Error: Expected Error: connect ECONNREFUSED 127.0.0.1:3000 to be null.
at
at Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:57:21)
at self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22)
at Request.emit (events.js:160:13)
at Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8)
at ClientRequest.emit (events.js:160:13)
at Socket.socketErrorListener (_http_client.js:389:9)
at Socket.emit (events.js:160:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:152:19)
Message:
Expected undefined to contain 'New Flair'.
Stack:
Error: Expected undefined to contain 'New Flair'.
at
at Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:58:22)
at self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22)
at Request.emit (events.js:160:13)
at Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8)
at ClientRequest.emit (events.js:160:13)
at Socket.socketErrorListener (_http_client.js:389:9)
at Socket.emit (events.js:160:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:152:19)
1 spec, 1 failure
Finished in 0.399 seconds
npm ERR! Test failed. See above for more details.
.......
So, removing the server call at least lets Jasmine run.
Any help on this is appreciated. Thank you for helping a novice programmer.
I found the source of the error.
Using git diff v0.1.2..v0.1.3 I was able to see the differences between the last working branch, and the current one.
From here, I saw that in db/src/controllers/flairController.js I had placed this in the controller for the flair object:
const flairQueries = require("./db/queries.flairs.js");
The problem with that is that the directory isn't correct. I replaced it with this:
const flairQueries = require("../db/queries.flairs.js");
After this, the Jasmine test suite worked.
I understand that this means that the controller couldn't load properly. The full understanding of this is still elusive, so if anyone has time to try to explain, I would appreciate it. Otherwise, we can consider this question closed. Thanks!

node.js Error (dgram.js) throw new TypeError('First argument must be a buffer object.');

I've developed a server for Intel Galileo in nodejs, which works perfectly fine on nodejs for windows.
The problem is when I tried to run it into Intel Galileo. It gives me this error:
dgram.js:248
throw new TypeError('First argument must be a buffer object.');
^
TypeError: First argument must be a buffer object.
at Socket.send (dgram.js:248:11)
at Socket.<anonymous> (/media/mmcblk0p1/Server/server2.js:21:12)
at Socket.g (events.js:180:16)
at Socket.EventEmitter.emit (events.js:92:17)
at startListening (dgram.js:141:10)
at dgram.js:216:7
at dns.js:72:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
code where the error appears:
var dgram=require("dgram");
var udpServer=dgram.createSocket("udp4");
udpServer.bind(8888, function(){
udpServer.setBroadcast(true);
udpServer.send("HIA",0,3,8888,"255.255.255.255",function(err){if(err)console.log(err)});
});
I'm trying to send a broadcast message with the text "HIA", but it seems it needs a buffer as parameter. This is not what the API says...
I guess the problem is that Intel Galileo has a different version of Node, but I've tried to update it unsuccessfully.
So use a Buffer instead:
var message = new Buffer('HIA');
udpServer.send(message, 0, message.length, ...)

Error starting Juggernaut

When I try to start Juggernaut I get this error :
1 Apr 20:21:01 - socket.io ready - accepting connections
node_redis: no callback to send error: ERR unknown command 'subscribe'
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: ERR unknown command 'subscribe'
at RedisReplyParser.<anonymous> (/usr/local/lib/node/.npm/redis/0.5.9/packag
e/index.js:84:27)
at RedisReplyParser.emit (events.js:64:17)
at RedisReplyParser.send_error (/usr/local/lib/node/.npm/redis/0.5.9/package
/lib/parser/javascript.js:251:14)
at RedisReplyParser.execute (/usr/local/lib/node/.npm/redis/0.5.9/package/li
b/parser/javascript.js:110:22)
at RedisClient.on_data (/usr/local/lib/node/.npm/redis/0.5.9/package/index.j
s:328:27)
at Socket.<anonymous> (/usr/local/lib/node/.npm/redis/0.5.9/package/index.js
:99:14)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:672:14)
at IOWatcher.onReadable [as callback] (net.js:177:10)
I didnt find anything to help me!
Try upgrading Redis.
It happened to me, and that's what solved it. I'm using Ubuntu, and the one in the package manager isn't an updated version. It needs to be at least version 2.2.1.
Source: From one of the issues posted on the juggernaut github repo.
EDIT: Upon closer inspection, it looks like you were the one who posted the issue on the github repo. I'll just leave this answer here just in case anyone else has the same problem.

Resources