Closed JamesNewton closed 3 years ago
To narrow this down, I use the source code of node-ping to write code that does the same thing, in a very minimal version inside the electron app. "out" is just console log, but it goes to a special text box which is easy to see while the program is running.
var cp = require('child_process');
ping = cp.spawn("ping", ["192.168.0.142"]);
ping.stdout.on('data', (data) => {
out(`stdout: ${data}`);
});
ping.stderr.on('data', (data) => {
out(`stderr: ${data}`);
});
ping.on('close', (code) => {
out(`child process exited with code ${code}`);
});
the stderr message comes back as stderr: ping: icmp open socket: Operation not permitted
and the child process existed with code 2.
Why doesn't node-ping report an error? Maybe I wrote the minimal code incorrectly? But the same code runs just fine under node, so electron is failing to run it with the same permissions...
Wonder if it's related to this: https://github.com/electron/electron/issues/18521
Submitted a bug report to Electron. https://github.com/electron/electron/issues/27168
Try 0.4.1, and see whether the error stderr: ping: icmp open socket: Operation not permitted
can be reported now
Sorry, it's been 4 months so we moved on and are no longer using this library at all. Rather than pretend that I could find time to revert, update the library and try it, I will just let you know that testing won't happen. Close this issue if you feel you've corrected the problem.
oops. Anyway, thanks for the report.
I'm baffled. Any insight on how to debug this appreciated. We are using ping to check if a robot is online before we attempt to connect to it. The specific code is: https://github.com/cfry/dde/blob/master/core/robot.js#L1049
copied here for your convenience: (and THIS code IS open source, so I can share it)
On Windows, and Mac, this code is working (e.g. reaching the "if (isAlive)" clause when the robot is online and pingable. In Ubuntu 16 and 18, it is reaching the "else {" clause, not the "else if (err) {" clause.
At the same time, on the same Ubuntu 18 machine, a ping to the same IP address from bash is returned, and the following little node.js test code works as expected, reporting "Dex is alive" every time:
I have searched the electron issues for any mention of ping not working. e.g. https://github.com/electron/electron/issues?q=is%3Aissue+%22node-ping%22+ and I'm not finding anything.
I've also, of course, searched your issues for anything related to electron and none of that seems to match: https://github.com/danielzzz/node-ping/issues?q=is%3Aissue+electron
I'm sort of at a point of... I don't know how to go forward here. It's probably an electron issue, but I was hoping you might have some ideas.