danielzzz / node-ping

a poor man's ping library (using udp scanning) for node
MIT License
336 stars 105 forks source link

processBody windows bug #72

Closed danhanfry closed 6 years ago

danhanfry commented 7 years ago

there is a case in windows that fails

this._times.push(parseFloat(match[1], 10));
TypeError: Cannot read property '1' of null

domain: hotel-capitol-kuala-lumpur.com

the error is in win.js

some answers are different

[ 'bytes=32', 'tiempo<1m', 'TTL=128' ]

they do not contain ms

var timeKVP = __.find(kvps, function (kvp) {
  return kvp.indexOf('ms') >= 0;
});

the solution is very easy. I hope you update it. a greeting

mondwan commented 7 years ago

Can you post a full example about how a ping response is look like in your language?

2017年10月19日 18:33 於 "DanHanfry" notifications@github.com 寫道:

there is a case in windows that fails

domain: hotel-capitol-kuala-lumpur.com

the error is in win.js

some answers are different

[ 'bytes=32', 'tiempo<1m', 'TTL=128' ]

they do not contain ms

var timeKVP = __.find(kvps, function (kvp) { return kvp.indexOf('ms') >= 0; });

the solution is very easy. I hope you update it. a greeting

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danielzzz/node-ping/issues/72, or mute the thread https://github.com/notifications/unsubscribe-auth/ADuAo0YCM80_E_06vsP34hJpxp8e9wk_ks5st_hSgaJpZM4QAEr6 .

mondwan commented 7 years ago

Here is an example pull request which is a good reference for an example of ping output we need.

https://github.com/danielzzz/node-ping/pull/71/files

Please provide us one. Otherwise, we cannot implement them correctly.

nguiard commented 7 years ago

I'm experiencing the same issue with a french windows install. Example successful ping output:

Réponse de 8.8.8.8 : octets=32 temps=22 ms TTL=127
infnada commented 7 years ago

Same error Spanish Win 7 on Git Bash:

C:\\node_modules\ping\lib\parser\win.js:56
        this._times.push(parseFloat(match[1], 10));
                                         ^

TypeError: Cannot read property '1' of null
    at WinParser._processBody (C:\node_modules\ping\lib\parser\win.js:56:42)
    at WinParser.parser.eat (C:\node_modules\ping\lib\parser\base.js:125:14)
    at C:\node_modules\ping\node_modules\underscore\underscore.js:73:21
    at Function._.each._.forEach (C:\node_modules\ping\node_modules\underscore\underscore.js:153:9)
    at ChildProcess.<anonymous> (C:\node_modules\ping\lib\ping-promise.js:76:12)
    at ChildProcess.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Haciendo ping a 172.17.2.2 con 32 bytes de datos: Respuesta desde 172.17.2.2: bytes=32 tiempo<1m TTL=64

Haciendo ping a 8.8.8.8 con 32 bytes de datos: Respuesta desde 8.8.8.8: bytes=32 tiempo=11ms TTL=55

mondwan commented 7 years ago

Please provide few of full examples for ping program in your language on window

2017年10月23日 03:27 於 "nada" notifications@github.com 寫道:

Same error Spanish Win 7 on Git Bash:

C:\node_modules\ping\lib\parser\win.js:56 this._times.push(parseFloat(match[1], 10)); ^

TypeError: Cannot read property '1' of null at WinParser._processBody (C:\node_modules\ping\lib\parser\win.js:56:42) at WinParser.parser.eat (C:\node_modules\ping\lib\parser\base.js:125:14) at C:\node_modules\ping\nodemodules\underscore\underscore.js:73:21 at Function..each._.forEach (C:\node_modules\ping\node_modules\underscore\underscore.js:153:9) at ChildProcess. (C:\node_modules\ping\lib\ping-promise.js:76:12) at ChildProcess.g (events.js:291:16) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:886:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Haciendo ping a 172.17.2.2 con 32 bytes de datos: Respuesta desde 172.17.2.2: bytes=32 tiempo<1m TTL=64

Haciendo ping a 8.8.8.8 con 32 bytes de datos: Respuesta desde 8.8.8.8: bytes=32 tiempo=11ms TTL=55

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/danielzzz/node-ping/issues/72#issuecomment-338616217, or mute the thread https://github.com/notifications/unsubscribe-auth/ADuAo_9OdVNJIFSISuHsJj-eDfwSaB7Vks5svGoEgaJpZM4QAEr6 .

ubcent commented 7 years ago

I had the same error on Russian Win10. Output of ping looks like following:

ping 8.8.8.8
Обмен пакетами с 8.8.8.8 по с 32 байтами данных:
Ответ от 8.8.8.8: число байт=32 время=37мс TTL=55
Ответ от 8.8.8.8: число байт=32 время=33мс TTL=55
Ответ от 8.8.8.8: число байт=32 время=38мс TTL=55
Ответ от 8.8.8.8: число байт=32 время=34мс TTL=55

Статистика Ping для 8.8.8.8:
    Пакетов: отправлено = 4, получено = 4, потеряно = 0
    (0% потерь)
Приблизительное время приема-передачи в мс:
    Минимальное = 33мсек, Максимальное = 38 мсек, Среднее = 35 мсек
ubcent commented 6 years ago

Hi there

Any updates? I wonder if somebody still maintains the project. Does it make sense to make PR with a fix?

danielzzz commented 6 years ago

yes, sorry I am very busy with other projects, but please do send a PR and as soon as @mondwan will confirm it I will try to push it upstream asap. thanks, dan

mondwan commented 6 years ago

How come there are so many variations on window to show an unit :(

mondwan commented 6 years ago

After reading samples and discussions, here is the list units?

[en,fr,ja,zh] -> [ms]
[ru] -> [мс, мсек]
[es] ->[m, ms]

I will try to change and search with the list of units as specified above later on...

ubcent commented 6 years ago

If you don't mind, I can help.

ubcent commented 6 years ago

By the way, guys, could you please bump the package version? I just want to update my deps.

mondwan commented 6 years ago

Sure. We are welcome for PRs :D

mondwan commented 6 years ago

Move the discussions and suggestions to #80

stark-ace-1891 commented 4 years ago

Modify the win.js file The error is due to the fact that in the code it looks for the text 'ms' and when it does not get results it gets an undefined in the variable' timeKVP ', sometimes when the answer is very fast the text does not contain this text but if the' m ', for this reason we modify line 55 as follows: stake