I am working with Bluemix tutorial recipe "Real Time Data Analysis Using IBM Watson IoT Platform Analytics" presented here:
https://developer.ibm.com/recipes/tutorials/real-time-data-analysis-using-ibm-watson-iot-platform-analytics
I am not seeing the behavior in my Watson IoT dashboard as described; the phone device does connect and register itself but I see no events or data.
In the node server logs a couple things seem concerning:
404 on fetch of util.js; in fact that file is not in my code repository downloaded from the recipe's github.
Three deprecated warnings:
...deprecated multipart: use parser (multiparty, busboy, formidable) npm module instead at node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:56:20
...deprecated limit: Restrict request size at location of read at node_modules/express/node_modules/connect/lib/middleware/multipart.js:86:15
...deprecated methodOverride: use method-override npm module instead at app.js:63:17
The phone device shows some fluttering data values but stays in state "connecting". On the WatsonIoT dashboard it shows registered but "Disconnected".
Is the missing util.js a fatal condition? If not then how next to troubleshoot it as I am new to the whole package?
Solved. The recipe checks for whether it needs to create its cloudant database, unaware that I'm sharing my cloudant service instance with other apps; it finds a db exists, blithely assumes that's the one it needs, and skips the create. Change app.js from:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.length == 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create('device_credentials', function()
to e.g.:
cloudant.db.list(function(err, all_dbs) {
if (all_dbs.indexOf(dbName) < 0) {
// first time -- need to create the iotzone-devices database
cloudant.db.create(dbName, function()
[etc...]
With the db in place, WatsonIoT accepts events coming from phone and shows the data as expected.
I found this by following the print statements in log.
Related
I just setup dozens of web scenario checks in Zabbix. I also added triggers and one action for all the triggers. To test the action I deployed a test bad web scenario check, however an email message I got from the test only gave very high-level information:
Problem: Service "Jira-QAS" is DOWN
-----------------------------------------------------------------------------
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Status: PROBLEM
Value: 1
Original problem ID: 2314429
-----------------------------------------------------------------------------
I want to parse "Last error message of scenario ..." as a macro and put it in the "default message" in "Action", so it would look something like this:
Problem: Service "Jira-QAS" is DOWN
-----------------------------------------------------------------------------
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Issue: Couldn't connect to server: Failed connect to jira-qas.aws.ca:443; Connection refused
Original problem ID: 2314429
-----------------------------------------------------------------------------
I tried different macros such as {ITEM.VALUE}, {EVENT.STATUS}, but neither of them were good enough.
You need to define Operational Data in the trigger, and add {EVENT.OPDATA} to the mail.
Operational data allow to define arbitrary strings along with macros. The macros will resolve dynamically to real time data in Monitoring → Problems. While macros in the trigger name (see above) will resolve to their values at the moment of a problem happening and will become the basis of a static problem name, the macros in the operational data maintain the ability to display the very latest information dynamically.
The same set of macros is supported as in the trigger name.
https://www.zabbix.com/documentation/current/manual/config/triggers/trigger
I've downloaded the sample project of the Android client from the HUAWEI Developers official website
After installing it on the mobile phone, I want to add a membership card to HUAWEI Wallet.
The demo provides two methods for adding a pass. The key code is as follows:
public void saveToHuaWeiWallet(View view) {
String jwtStr = getJwtFromAppServer(passObject);
CreateWalletPassRequest request = CreateWalletPassRequest.getBuilder()
.setJwt(jwtStr)
.build();
Log.i("testwalletKIT", "getWalletObjectsClient");
walletObjectsClient = Wallet.getWalletPassClient(PassTestActivity.this);
Task<AutoResolvableForegroundIntentResult> task = walletObjectsClient.createWalletPass(request);
ResolveTaskHelper.excuteTask(task, PassTestActivity.this, SAVE_TO_ANDROID);
}
No matter which method I use for adding a pass, error code -1 is returned. I didn't find any description of the error code in the official documentation. Can anyone tell me why error code -1 is returned?
Parameter error. The possible causes are as follows:
No template is created for the passes. Add a template by referring to the following. https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/wallet-guide-webpage
The pass has already been added. Enter the unique ID (serinumber) of another pass.
The template ID and service number are incorrect. Enter the values of passStyleIdentifier and passTypeIdentifier fields used during template creation on the server side.
Incorrect IssuerId. Enter the app ID generated app creation in AppGallery Connect.
I'm setting up a new mqtt conection in my app but there is a problem when i would like to create the main connection of mqtt.
I'm using mqtt.js.
I've tried all what is done in MQTT documentation but nothing happens..
mqttFunction(){
var mqtt = require('mqtt');
var client = mqtt.connect([{host: 'localhost', port: '1883'},]);
client.subscribe('presence')
client.on('message', function (topic, message) {
console.log(message);
});
}
I expect the output of the mqtt broker to be 'ON' when i asked it to respond.
The error is: ERROR ReferenceError: process is not defined
The documentation you followed is intended for Node.js and various other back-end JavaScript frameworks. Even though it uses NPM, Ionic ultimately produces a front-end framework, and its applications run a bit differently.
For example, Ionic programs may not have a global process variable like Node.js. mqtt.js expects this variable, with code like:
if (commist.parse(process.argv.slice(2)) !== null){...}
You could declare a process object, and get past this particular error. Other obstacles could come up.
var process = {env : {NODE_ENV: 'production'}}
If there are still issues with that, you could try the instructions for browser usage, which point to a specially compiled version, like https://unpkg.com/mqtt#3.0.0/dist/mqtt.min.js. I have had less luck with mqtt.js in the browser, and you may want an alternative like web-mqtt-cient / Paho if more complex connections are involved.
I have tried the following javascript code, using a railway API in aog for getting names of trains between 2 stations.
train : function(conv,src,dst) {
const options={
method:'GET',
url : `https://api.railwayapi.com/v2/between/source/${src}/dest/${dst}/date/23-09-2018/apikey/<api_key>/`,
json : true
};
var data=[];
return rp(options)
.then(function(parseBody){
for(var i=0;i<2;i++){
data.push(parseBody.trains[i].name);
}
console.log(data);
return conv.ask(data[0] + data[1]);
}).catch(err=>{
console.log("api error" + err);
});
}
When I run it in my computer using terminal(node filename.js) it shows the data[] array with correct values. But when I try to run it from actions-on-google simulator it catches an error as follows...
api errorRequestError: Error: getaddrinfo ENOTFOUND api.railwayapi.com api.railwayapi.com:443
If you are trying to do this using Firebase Cloud Functions (FCF) or the Dialogflow Built-In editor (which uses FCF under the covers), the most likely cause is that you are using the free tier of FCF which does not allow calls outside Google's network.
You can upgrade to the Blaze Plan to get around this. While this does require a credit card to be on file, it includes a free tier which is quite sufficient for some basic testing and probably even some very light usage once you're in production. Once you have your Action approved, you will be eligible to receive cloud credits from Google which can be used to offset costs associated with using Cloud Functions.
We built an app in Zend Framework (v1) and have not worked a lot in setting up error reporting and logging. Is there any way we could get some level or error reporting without too much change in the code? Is there a ErrorHandler plugin available?
The basic requirement is to log errors that happens within the controller, missing controllers, malformed URLs, etc.
I also want to be able to log errors within my controllers. Will using error controller here, help me identify and log errors within my controllers? How best to do this with minimal changes?
I would use Zend_Log and use the following strategy.
If you are using Zend_Application in your app, there is a resource for logging. You can read more about the resource here
My advice would be to choose between writing to a db or log file stream. Write your log to a db if you plan on having some sort of web interface to it, if not a flat file will do just fine.
You can setup the logging to a file with this simple example
resources.log.stream.writerName = "Stream"
resources.log.stream.writerParams.stream = APPLICATION_PATH "/../data/logs/application.log"
resources.log.stream.writerParams.mode = "a"
resources.log.stream.filterName = "Priority"
resources.log.stream.filterParams.priority = 4
Also, I would suggest sending Critical errors to an email account that is checked regularly by your development team. The company I work for sends them to errors#companyname.com and that forwards to all of the developers from production sites.
From what I understand, you can't setup a Mail writer via a factory, so the resource won't do you any good, but you can probably set it up in your ErrorController or Bootstrap.
$mail = new Zend_Mail();
$mail->setFrom('errors#example.org')
->addTo('project_developers#example.org');
$writer = new Zend_Log_Writer_Mail($mail);
// Set subject text for use; summary of number of errors is appended to the
// subject line before sending the message.
$writer->setSubjectPrependText('Errors with script foo.php');
// Only email warning level entries and higher.
$writer->addFilter(Zend_Log::WARN);
$log = new Zend_Log();
$log->addWriter($writer);
// Something bad happened!
$log->error('unable to connect to database');
// On writer shutdown, Zend_Mail::send() is triggered to send an email with
// all log entries at or above the Zend_Log filter level.
You will need to do a little work to the above example but the optimal solution would be to grab the log resource in your bootstrap file, and add the email writer to it, instead of creating a second log instance.
You can use Zend_Controller_Plugin_ErrorHandler . As you can see on the documentation page there is an example that checks for missing controller/action and shows you how to set the appropriate headers.
You can then use Zend_Log to log your error messages to disk/db/mail.