Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getConnection() return null #34

Open
JohnPekl opened this issue Aug 5, 2017 · 0 comments
Open

getConnection() return null #34

JohnPekl opened this issue Aug 5, 2017 · 0 comments

Comments

@JohnPekl
Copy link

JohnPekl commented Aug 5, 2017

I tried to run the example from here. (http://lorenwest.github.io/node-monitor/doc/classes/Monitor.html)

Though I received data from Server periodically, the function processMonitor.getConnection() return null.
Also, the function processMonitor.control('ping', function(error, response), return null due to the error [ERROR] Monitor.control.Process.ping - Probe not connected

server.js
`var Monitor = require('monitor');

var options = {
probeClass: 'Process',
initParams: {
pollInterval: 10000
}
}
var Probe = new Monitor.Probe(options);
Probe.onControl('ping', function(error, response) {
response = 'asdasdasd';//console.log('Ping response: ', response);
});

var server = new Monitor.Server();
server.start();`

client.js
`var options = {
hostName: '192.168.2.3',
probeClass: 'Process',
initParams: {
pollInterval: 10000
}
}
var Monitor = require('monitor');
// Connecting a monitor to a probe
var processMonitor = new Monitor(options);
processMonitor.connect(function(err) {console.log('aa', err);});

//var Connection = Monitor.Connection(options);

// Monitoring the probe
processMonitor.on('change', function(){
console.log('Changes:', processMonitor.get('freemem'));
});

// Remote control
processMonitor.control('ping', function(error, response) {
console.log('Ping response: ', response);
});

console.log('getConnection()', processMonitor.getConnection());`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant