Comments (18)
That is the return code from calling ping... 0 = success.
The result is passed in the message as msg.payload which should be visible if you connect a debug node directly to the ping node.
Example flow..
[{"id":"415d9e6a.6894","type":"debug","name":"","active":true,"complete":false,"x":296.16667556762695,"y":102.1666841506958,"z":"f8cf4ab6.9daa1","wires":[]},{"id":"ac259a1.ab60968","type":"ping","name":"","host":"github.com","timer":"20","x":131.16667938232422,"y":101.16668510437012,"z":"f8cf4ab6.9daa1","wires":[["415d9e6a.6894"]]}]
If that still fails can you post your flow please.
(If you want to see the actual result in the console instead add a line in 88-ping.js
before line 47
console.log(msg);
node.send(msg);
for example I get - { payload: 117, topic: 'github.com' }
where 117 = 117mS
from node-red-nodes.
I believe I was also seeing msg.payload set to zero as well. I'll check and post debug flows when I can get back to my setup.
from node-red-nodes.
I have pasted in the flow you recommended, and added the debug output to the js file. I am still seeing zeroes:
[ping] stdout: PING github.com (192.30.252.129) 56(84) bytes of data.
64 bytes from 192.30.252.129: icmp_req=1 ttl=50 time=105 ms
[ping] stdout:
--- github.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 105.634/105.634/105.634/0.000 ms
[ping] result: 0
{ payload: 0, topic: 'github.com' }
I notice there is text saying "time 0ms", above the line that lists the rtt statistics. Could that be the source of the confusion?
from node-red-nodes.
I left it running, and noticed one non-zero value in a load of zeroes. Flow and debug is as before.
[ping] stdout: PING github.com (192.30.252.129) 56(84) bytes of data.
64 bytes from 192.30.252.129: icmp_req=1 ttl=50 time=95.4 ms
--- github.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 95.432/95.432/95.432/0.000 ms
[ping] result: 0
{ payload: 95.4, topic: 'github.com' }
from node-red-nodes.
Aha - yes - the "easy" fix should be to change line 36 to be
var regex = /from.time.(.)ms/;
Can you try that and report back ? Thanks
from node-red-nodes.
I tried the proposed regex line, but got NaN this time:
[ping] stdout: PING github.com (192.30.252.130) 56(84) bytes of data.
64 bytes from 192.30.252.130: icmp_req=1 ttl=51 time=98.9 ms
[ping] stdout:
--- github.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 98.974/98.974/98.974/0.000 ms
[ping] result: 0
{ payload: NaN, topic: 'github.com' }
from node-red-nodes.
Is there a way to see GitHub raw text rather than the formatted version? Has the mark-down hidden some of the regex line - it looks oddly formatted? I may have used the wrong regex in that case...!
from node-red-nodes.
DOH...... yes is has... sorry - was typing on a train... should have spotted that as it wasn't going anywhere fast....
var regex = /from.*time.(.*)ms/;
we are adding in from.* to the front of the existing regex.
from node-red-nodes.
Still NaN, even with the corrected regex.
from node-red-nodes.
OK - final piece of remote debug...
can you add a line after line 37 - var m = ...
console.log(m);
and paste the resulting output. Thanks.
(I won't have access to my Pi until later tomorrow so apologies for using you as a guinea pig)
from node-red-nodes.
OK, done that.
[ping] stdout: PING github.com (192.30.252.131) 56(84) bytes of data.
64 bytes from 192.30.252.131: icmp_req=1 ttl=49 time=104 ms
[ 'from 192.30.252.131: icmp_req=1 ttl=49 time=104 ms',
'104 ',
index: 64,
input: 'PING github.com (192.30.252.131) 56(84) bytes of data.\n64 bytes from 192.30.252.131: icmp_req=1 ttl=49 time=104 ms\n' ]
[ping] stdout:
--- github.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 104.830/104.830/104.830/0.000 ms
[ '' ]
[ping] result: 0
{ payload: NaN, topic: 'github.com' }
from node-red-nodes.
Correct - am having a bad day... commuting to London...
how about lines 37 38..... :-)
var m = regex.exec(data.toString())||""; if (m != '') { res = Number(m[1]); }
so it only sets it if a valid parse.
from node-red-nodes.
That looks like it's doing the right thing now. I'm consistently getting the ping times in the msg.payload.
from node-red-nodes.
OK great - I'll push the fix - but please let us know if it misbehaves.
Many thanks for your help and patience.
from node-red-nodes.
Hmm... and there was me patching something similar a few weeks ago :-)
from node-red-nodes.
Now he tells us :-)
share and share again.
from node-red-nodes.
cough #18 - admittedly this might not have closed this too, but it was based on the same symptom originally.
from node-red-nodes.
Hello old friend ! so it is/was.... hopefully nailed this time.
from node-red-nodes.
Related Issues (20)
- [node-red-node-pi-gpio] on Venus OS and other non raspian OS
- Node-red Serial port output node, response time too long. HOT 5
- Node-red does not run on a FIPS crypto policy enabled OS HOT 2
- [Vulnerability] nodemailer ReDoS when trying to send a specially crafted email.
- EMAIL (node-red-node-email) , If msg.to is defined msg.paiload is ignored HOT 3
- node-red-node-email, send node "ReferenceError: msg is not defined" on deploy HOT 1
- node-red-node-email: authentication: none broken HOT 5
- select sqlite fail response
- Installation failed in latest node version above 18 HOT 1
- How can I disable the creation process? HOT 2
- Get datetime when qwery a date column HOT 2
- node-red-node-pi-gpio -> nrgpio.py uses ~1% CPU per IO port
- Node-red-node-email stops fetching GMail
- Gmail will soon require OAUTH credentials - "node-red-node-email" in jeopardy! HOT 3
- Node-red-node-email vulnerabilities HOT 1
- node-red-node-email unhelpful connect error HOT 4
- node-red-node-pushover support for attachment_base64 and attachment_type
- mcp3xxx node does not seem to recognise raspberry pi on a pi4 running bookworm HOT 3
- Stomp node: error sending payload as XML
- node-red-node-serialport message duplication
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-nodes.