Thing is not running
Hi,
So, I have a service which allow me to create a Thing based on a sshServerTemplate (from the ssh extension of the marketplace). When I call it it creates the thing and configure it (user/pass, url, port, ...) and it works perfectly.
I need to do the same thing with the sftp extension (also available on the marketplace) so I duplicated my service and changed some values in order to manage this. But when I execute the service it throws me an error : "Thing [<thingName>] is not running" ...
I tried to remove all the configuration part to just keep the creatething part and it works, the thing is created. But if i try to set Tags, project or even properties it throws me the error.
Below the code of my service (I know it is quite ugly) (the createThings service is an homemade service and the enableThing is called in this service) :
// Create sftp gateway
var thingName = gatewayName + "Sftp";
var params = {
Description: undefined /* STRING */,
ThingName: thingName /* STRING */,
ThingTemplate: "SftpGatewayTemplate" /* STRING */,
Tag: undefined /* STRING */
};
me.CreateThings(params);
Things[thingName].RestartThing();
var params = {
tags: [{
vocabulary: "Smart Building",
vocabularyTerm: tagTerm
}] /* TAGS */
};
Things[thingName].SetTags(params);
Things[thingName].RestartThing();
var params = {
projectName: tagTerm /* PROJECTNAME */
};
Things[thingName].SetProjectName(params);
Things[thingName].RestartThing();
var params1 = {
defaultValue: gatewayUrl /* STRING */,
description: undefined /* STRING */,
readOnly: undefined /* BOOLEAN */,
type: "STRING" /* BASETYPENAME */,
remote: undefined /* BOOLEAN */,
remotePropertyName: undefined /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined /* STRING */,
dataChangeThreshold: undefined /* NUMBER */,
logged: undefined /* BOOLEAN */,
name: "URL" /* STRING */,
pushThreshold: undefined /* NUMBER */,
dataChangeType: undefined /* STRING */,
category: undefined /* STRING */,
persistent: true /* BOOLEAN */,
dataShape: undefined /* DATASHAPENAME */
};
Things[thingName].AddPropertyDefinition(params1);
Things[thingName].RestartThing();
var params1 = {
defaultValue: gatewayLoc /* STRING */,
description: undefined /* STRING */,
readOnly: undefined /* BOOLEAN */,
type: "STRING" /* BASETYPENAME */,
remote: undefined /* BOOLEAN */,
remotePropertyName: undefined /* STRING */,
timeout: undefined /* INTEGER */,
pushType: undefined /* STRING */,
dataChangeThreshold: undefined /* NUMBER */,
logged: undefined /* BOOLEAN */,
name: "Localisation" /* STRING */,
pushThreshold: undefined /* NUMBER */,
dataChangeType: undefined /* STRING */,
category: undefined /* STRING */,
persistent: true /* BOOLEAN */,
dataShape: undefined /* DATASHAPENAME */
};
Things[thingName].AddPropertyDefinition(params1);
Things[thingName].RestartThing();
Things[thingName].EnableThing();
Things[thingName].RestartThing();
var params = {
infoTableName : "InfoTable",
dataShapeName : "SshConf"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(SshConf)
var infTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var params = {
data: password /* STRING */
};
// result: STRING
var pass = Resources["EncryptionServices"].EncryptPropertyValue(params);
// SshConf entry object
var newEntry = new Object();
newEntry.password = pass; // PASSWORD
newEntry.keepAliveTimeout = keepTimeout; // NUMBER
newEntry.port = port; // NUMBER
newEntry.host = gatewayUrl; // STRING - isPrimaryKey = true
newEntry.connectionTimeout = conTimeout; // NUMBER
newEntry.username = user; // STRING
infTable.AddRow(newEntry);
var params = {
configurationTable: infTable /* INFOTABLE */,
persistent: true /* BOOLEAN */,
tableName: "ConnectionInfo" /* STRING */
};
Things[thingName].SetConfigurationTable(params);
Things[thingName].SaveConfigurationTables();
Things[thingName].RestartThing();
Thanks for your help

