Hi,
I'm using the tcp-ping module and also installed the node_modules for that in apigee.
Please find below is the node js code.
var tcpp = require('tcp-ping'); tcpp.probe('www.google.com', 80, function(err, available) { console.log(available); }); tcpp.ping({ address: 'www.google.com' }, function(err, data) { console.log(data); });
When I test this, I'm getting 500 internal server error.
{"fault":{"faultstring":"Script node executed prematurely: Script nj-ping.js exited with status code 0","detail":{"errorcode":"scripts.node.runtime.ScriptExitedError"}}}
Scriptoutput is as below.
*** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 29.552331, max: 59.545281, min: 25.998569, results: [ { seq: 0, time: 59.545281 }, { seq: 1, time: 26.29472 }, { seq: 2, time: 25.998569 }, { seq: 3, time: 26.159917 }, { seq: 4, time: 26.31019 }, { seq: 5, time: 26.414659 }, { seq: 6, time: 26.387812 }, { seq: 7, time: 26.120186 }, { seq: 8, time: 26.178659 }, { seq: 9, time: 26.113317 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 28.099805500000002, max: 46.232003, min: 25.688347, results: [ { seq: 0, time: 26.719822 }, { seq: 1, time: 26.225708 }, { seq: 2, time: 25.802322 }, { seq: 3, time: 46.232003 }, { seq: 4, time: 25.688347 }, { seq: 5, time: 25.917152 }, { seq: 6, time: 26.085629 }, { seq: 7, time: 26.435544 }, { seq: 8, time: 25.987074 }, { seq: 9, time: 25.904454 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script { address: 'www.google.com', port: 80, attempts: 10, avg: 29.339385400000005, max: 59.034029, min: 25.57112, results: [ { seq: 0, time: 59.034029 }, { seq: 1, time: 26.33388 }, { seq: 2, time: 26.297341 }, { seq: 3, time: 25.746513 }, { seq: 4, time: 25.787845 }, { seq: 5, time: 26.122622 }, { seq: 6, time: 26.049475 }, { seq: 7, time: 25.907924 }, { seq: 8, time: 25.57112 }, { seq: 9, time: 26.543105 } ] } true *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 29.479161599999998, max: 58.902149, min: 25.94649, results: [ { seq: 0, time: 58.902149 }, { seq: 1, time: 26.431136 }, { seq: 2, time: 25.94649 }, { seq: 3, time: 26.240265 }, { seq: 4, time: 26.267003 }, { seq: 5, time: 25.956701 }, { seq: 6, time: 26.216872 }, { seq: 7, time: 26.70566 }, { seq: 8, time: 26.045721 }, { seq: 9, time: 26.079619 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 30.664022900000003, max: 59.057425, min: 25.825715, results: [ { seq: 0, time: 59.057425 }, { seq: 1, time: 25.825715 }, { seq: 2, time: 26.5129 }, { seq: 3, time: 26.051442 }, { seq: 4, time: 26.129827 }, { seq: 5, time: 26.161203 }, { seq: 6, time: 26.01639 }, { seq: 7, time: 38.175671 }, { seq: 8, time: 26.191469 }, { seq: 9, time: 26.518187 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 29.645783299999994, max: 60.07772, min: 25.955065, results: [ { seq: 0, time: 60.07772 }, { seq: 1, time: 25.955065 }, { seq: 2, time: 26.321326 }, { seq: 3, time: 26.552822 }, { seq: 4, time: 26.130396 }, { seq: 5, time: 26.416793 }, { seq: 6, time: 26.399723 }, { seq: 7, time: 26.400152 }, { seq: 8, time: 26.083942 }, { seq: 9, time: 26.119894 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 31.621371999999997, max: 59.96495, min: 25.60728, results: [ { seq: 0, time: 59.96495 }, { seq: 1, time: 25.854694 }, { seq: 2, time: 26.355518 }, { seq: 3, time: 25.996082 }, { seq: 4, time: 26.615463 }, { seq: 5, time: 26.137608 }, { seq: 6, time: 47.800928 }, { seq: 7, time: 25.87297 }, { seq: 8, time: 26.008227 }, { seq: 9, time: 25.60728 } ] } *** Script nj-ping.js exited with status code 0 *** Starting script true { address: 'www.google.com', port: 80, attempts: 10, avg: 29.488880900000005, max: 60.611127, min: 25.622124, results: [ { seq: 0, time: 60.611127 }, { seq: 1, time: 25.772864 }, { seq: 2, time: 26.375957 }, { seq: 3, time: 26.064949 }, { seq: 4, time: 25.622124 }, { seq: 5, time: 25.936646 }, { seq: 6, time: 26.152048 }, { seq: 7, time: 26.283004 }, { seq: 8, time: 26.125113 }, { seq: 9, time: 25.944977 } ] } *** Script nj-ping.js exited with status code 0
Please assist on this in resolving this.
Thanks,
Bindu
Solved! Go to Solution.
Hi @Bindu.Kadiyala,
Apigee has restricted support for Node's "net" module which is being used internally by tcp-ping. Please refer the documentation for the same here.
http://docs.apigee.com/api-services/content/understanding-edge-support-nodejs-modules
If your use case is to check if target server has the specified port open or not, then you can use the "Health Monitor" feature of Target Endpoint configurations. It allows both HTTP and TCP monitoring.
Details for the same can be found at below link.
http://docs.apigee.com/api-services/content/load-balancing-across-backend-servers#healthmonitoring
Hope this helps.