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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to return several InfoTable from service?如何一次性从Service中返回五六个InfoTable?

yingziDing
4-Participant

How to return several InfoTable from service?如何一次性从Service中返回五六个InfoTable?

The return value type of the service is InfoTable. And I know that the column type can also be InfoTable. But, when I put five or six InfoTable in one row and return it to the client, the client side throws TimeoutException. I mean that I call the invokeService method (Java SDK), and set 60s to the timeout parameter, it's also timeout! Always timeout every time.I try to return just one InfoTable, it works. And then I try to return 2 or 3 InfoTables, it also work. But when I try to return 4 InfoTables, it is timeout. Sometimes return 3 InfoTable also timeout. It's unpredictable!

Are there any restrictions in return value?


Following is the definition of return value. There is just 3 InfoTables, if there is 4 or 5 InfoTables, the client will timeout. But today, 3 InfoTables also make client timeout, I don't know why. It's totally unpredictable! Are there any restrictions in return value? The number of rows in each InfoTable are not large.

QQ图片20170505115713.png

Service的返回值是InfoTable类型,通常里面是一行数据,带有几个字段,以此来返回数据,当需要返回的数据是InfoTable时,字段的类型可以是Infotable,这我知道,但是问题是现在我这么做了,但是却在客户端出现了invokeService超时的问题,InfoTable的数据量很少,每个InfoTable只有三四行,客户端调用invokeService设置超时时间60秒,仍然超时,服务器和客户端都在局域网,网速是没问题的。请问这是怎么回事?或者有什么别的解决方案以返回数个InfoTable,最好同时返回。

8 REPLIES 8
AnnaAn
13-Aquamarine
(To:yingziDing)

Dear yz ding,

Could you send me your sample code in Java SDK and the service called in invokeService in thingworx composer?

Thanks,

Br,

Anna

yingziDing
4-Participant
(To:AnnaAn)

QQ图片20170505143656.pngQQ图片20170505143711.png

AnnaAn
13-Aquamarine
(To:yingziDing)

Hi yz ding​,

What's your REQUEST_TIMEOUT value in your restoreData method in Java SDK?

Does your Java SDK installed on the same server to Thingworx?

Thanks,

Br,

Anna

AnnaAn
13-Aquamarine
(To:yingziDing)

Hi yz ding​,

Just let you know that the timeout in the invokeService is milliseconds, please check if the timeout you set is big enough.

Try to increase the timeout and see if issue is gone.

Thanks,

Br,

Anna

yingziDing
4-Participant
(To:AnnaAn)

private static final int REQUEST_TIMEOUT = 60000;

I wait REQUEST_TIMEOUT * 2 milliseconds and still time out!

Other parameter is all right. I have written many code like this, they are all work well. But those services is not return InfoTable. Just this one use InfoTable.

AnnaAn
13-Aquamarine
(To:yingziDing)

Hi yz ding​,

In your Java SDK, I see you are using AndroidConnectedThingClient, could you let me know if this is a class you created and is it extending the ConnectedThingClient class? What's your java SDK version? As far as I know, you could call a service from edge with:

1. create SimpleThingClient which extends from ConnectedThingClient

2. Create new SimpleThingClient Object: SimpleThingClient client = new SimpleThingClient(config);

3. Create ValueCollection and set parameters for service(i)

4. Call InvokeService with: client.invokeService(ThingworxEntityTypes.Things, "YOURTHINGNAME", "SERVICENAME", new ValueCollection(), 5000);

Could you try it and see if you got the same error?

Thanks,

Br,

Anna

yingziDing
4-Participant
(To:AnnaAn)

I use the official Android SDK provided by Thingworx. The version is 1.0.0.38.

AnnaAn
13-Aquamarine
(To:yingziDing)

Hi yz ding​,

I did not use Android SDK before, but I indeed did the similar work with Java SDK and it works fine.

One thing I could imagine is that you client may not be connected to ThingWorx when you call the services.

So it worth a try to wait some time for the client to connect to Thingworx server and then  you call invokeService.

Try to add code

// try to add this section code after client instance is created

// in my exmaple it's 30000 ms, but you could increase/decrease it to test

if (client.waitForConnection(30000)){

// invokeservice here

}

Thanks,

Br,

Anna

Top Tags