cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Thing is not running

jdurand
1-Visitor

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

ACCEPTED SOLUTION

Accepted Solutions

Some options:

  1. Create a dummy FTP Configuration that always works ( yourdomain, fakeUser, fakePassord --> No rights )
  2. Decompible the extension ( that's not hard if you get to know java ) and tweak it
  3. Open a support case, and nice people from Support they may improve the extension for you, they did for me in the past, who developed SFTP extension it's Europa based

View solution in original post

9 REPLIES 9

Hi,

I think that SFTP Thing tries to connect when it starts, and it may take too much... Then maybe when it's connecting the Thing it's not fully enabled. Just a guess.

Carles.

Hi,

I tried to prove your guess and it looks like it is not the problem.

I will try further in that way but if you have another idea feel free to share it with me !

Thanks

Ok finally it seems to be that, the Thing needs to connect once to the sftp server in order to have the "running" status.

So right now my problem is "how to programatically configure sftp server acces on a thing if the thing is not accessible until it has been configured ?" ..

Put a flag to mark if it's configured or not, and then with a timer try to configure it until it's.

PaiChung
22-Sapphire I
(To:CarlesColl)

You can also create an extended template that has a Subscription to ThingStart which kicks off the configuration

Hi Pai,

I think ThingStart will be thrown before the Thing it's correctly initialized, but he can give it a shot i conjunction with Configured Thing flag.

Carles.

Hi,

The problem is that until the thing has not been configured, I can't configure it programatically. It is a weird process but if I create the thing with the service and after that I spam the method to configure the thing it will never work.

Some options:

  1. Create a dummy FTP Configuration that always works ( yourdomain, fakeUser, fakePassord --> No rights )
  2. Decompible the extension ( that's not hard if you get to know java ) and tweak it
  3. Open a support case, and nice people from Support they may improve the extension for you, they did for me in the past, who developed SFTP extension it's Europa based

I already did the first option, it works but it is a bad way to do :/

I will contact the support to tell us about that.

Thanks for your help !!!

Announcements


Top Tags