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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

C SDK with additional Edge Microserver

areich
1-Visitor

C SDK with additional Edge Microserver

Hello All,

I am trying to use the SteamSensor example from the C SDK and I have the following requirements:

  • C SDK running on a Debian (Linux) client
  • Thingworx Server running on WIN 7

I have already created a thing from the RemoteThing Template and an application key in my Thingworx webbased GUI on my Windows 7.

I also adjust all the paramerts like host, port, appkey and so in my SteamSensor main.c.

When I am trying to run the example I got errors like this on my linux client:

tw_error03.png

Do I always need an additional Edge Micrsoserver with my Edge SDK running on my linux client? Or how can I handle this error?

Thank you so much!

Greetings

8 REPLIES 8
Aanjan
12-Amethyst
(To:areich)

Artur, how have you formatted your connection string?

areich
1-Visitor
(To:Aanjan)

What kind of connection string do you mean?

in main.c

#define TW_HOST "xxx.xx.xx.xx" //IP Adress of my thingworx server (I am able to ping the server from my client)

in twDefaultSettings.h

#define TW_URI "Thingworx/WS"

The Adress in the browser of my server is:

xxx.xx.xx.xx:8080/Thingworx/Composer/index.html

mhollenbach
12-Amethyst
(To:areich)

A 400 error is a bad/malformed request. What all have you modified in your code? Were you able to connect with OOTB source and modified AppKey, IP, and port?

Meghan

Hello Meghan,

I wasn't able to connect with the OOTB source so I modified some values.

In the main.c I modified the thingName to the name of the created thing in my Thnigworx Composer.

I also modified the TW_HOST and the TW_APP_KEY.

In the twTls.c I modified the two variables like

tls->validateCert = FALSE;

tls->isEnabled = FALSE;

because I got SSL Connection errors. After this modification I don't get this SSL errors anymore.

In the twDefaultSettings.h I don't modified something. My TW_URI looks like:

"Thingworx/WS"

Thank you for your response!

mhollenbach
12-Amethyst
(To:areich)

You don't want to go into the twTls.c or twDefaultSettings.h file and change anything right away. Let's start with a fresh copy of the OOTB C SDK and modify the following:

  1. char * thingName = "SteamSensor1"; <-- This should equal whatever the entity name you've created in ThingWorx as your RemoteThing
  2. #define TW_HOST "localhost" <-- If your server and C SDK are running on the same machine "localhost" will suffice
  3. #define TW_APP_KEY "1724be81-fa15-4485-a966-287bf8f6683c" <-- Obviously you'll need to fill in-between the quotation marks with your AppKey in your server
  4. In the beginning of the main function there is a port #if defined section. If you are using port 80 just put the line, #define NO_TLS, above that section in the main function
  5. The final part you'll want to add right around the top of the main function is twApi_DisableEncryption(); That will prevent you from having to go in and change those pointers in twTls.c

This should be all you need to do for proper communication to occur. If this still does not work let me know and post any error message you are seeing.

Meghan

So I have done the steps you mentioned on a fresh copy of the OOTB C SDK:

1. char * thingName = "exampleApp";

2. #define TW_HOST "172.27.30.68"      <-- my server is running on antother machine (WIN 7)

3. #define TW_APP_KEY "1724be81-fa15-4485-a966-287bf8f6683c"    <-- change this value to my generated app key

4.

  • I am not using port 80, so I don't add the #define NO_TLS. I am using the port 8080
  • I also tried it with changing the value below from 443 to 8080 in my previous trials
  • I think I have to change it to 8080 or is the 443 the port of a intern proxy?

5. I've added the twApi_DisableEncryption(); before the twApi_Initialize(); in the main function


No I am getting the following output. It seems there's no possibilty to build the socket.


tw_error05.png


If I am changing the port from 443 to 8080 I am getting the SSL Error again. This failure I have solved with changing the pointers in twTls.c, because i read about that in another dissucsion. So now I am getting this error without changing the pointers.


tw_error06.png

I also deactivated all firewalls server - sided, where my thingworx composser is running.


Thank you!

Also need to change the port (TW_PORT) since apparently the server is listening on 8080 and the SDK defaults to 80 when TLS is disabled

"The Adress in the browser of my server is:

xxx.xx.xx.xx:8080/Thingworx/Composer/index.html"

areich
1-Visitor
(To:jcanosa)

I changed the port to 8080, but then I'm getting the SSL error mentioned in the second screen cap in my last posting.

Greetings

Announcements


Top Tags