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

How to connect EMS to ThingWorx Composer without SSL

SOLVED
Highlighted
Level 7

How to connect EMS to ThingWorx Composer without SSL

 I am following the IoT Connectivity with Thingworx course and am trying to configure the json file for EMS to connect to my Thingworx server. It is running on http (no SSL). This is what I currently have in the json file.

{
    "ws_servers":    [{
            "host":    "http://192.168.1.170",
            "port":    80
        }],
    "appKey":    "ad2d631b-d6fe-45f0-a892-6dbc500fd339",
    "logger":   {
        "level":    "TRACE"
    },
    "certificates": {
        "validate": false
    },
    "http_server" : {
        "host": "localhost",
        "port":    8080,
        "ssl" : false,
        "authenticate": false        
    }
}

 

This is the error:

 

[WARN ] 2018-10-19 13:05:55,846 SDK: SDK Version: 2.0.4
[WARN ] 2018-10-19 13:05:55,847 SDK: TLS Library: OpenSSL
[WARN ] 2018-10-19 13:05:55,847 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-10-19 13:05:55,847 SDK: FIPS Capable
[DEBUG] 2018-10-19 13:05:55,847 SDK: twWs_Create: Initializing Websocket Client
for http://192.168.1.170:80//Thingworx/WS
[DEBUG] 2018-10-19 13:05:55,847 SDK: twTlsClient_Create: Initializing TLS Client

[TRACE] 2018-10-19 13:05:55,848 SDK: twSocket_Close: closing socket: 0, socket i
nfo - host: http://192.168.1.170, port: 80, proxyHost: NULL, proxyPort: 0, state
: 0
[DEBUG] 2018-10-19 13:05:55,848 SDK: twTlsClient_Close: Disconnecting from serve
r
[ERROR] 2018-10-19 13:05:55,848 SDK: twWs_Create: Error creating BSD socket to b
e used for the websocket
[ERROR] 2018-10-19 13:05:55,848 SDK: twApi_Initialize: Error creating websocket
structure, retrying
[FORCE] 2018-10-19 13:05:56,0 httpServer: starting http server port=8080
[DEBUG] 2018-10-19 13:05:56,3 httpServer: http server bound to port=8080.
[DEBUG] 2018-10-19 13:06:00,849 SDK: twWs_Create: Initializing Websocket Client
for http://192.168.1.170:80//Thingworx/WS
[DEBUG] 2018-10-19 13:06:00,849 SDK: twTlsClient_Create: Initializing TLS Client

[TRACE] 2018-10-19 13:06:00,849 SDK: twSocket_Close: closing socket: 0, socket i
nfo - host: http://192.168.1.170, port: 80, proxyHost: NULL, proxyPort: 0, state
: 0
[DEBUG] 2018-10-19 13:06:00,849 SDK: twTlsClient_Close: Disconnecting from serve
r
[ERROR] 2018-10-19 13:06:00,849 SDK: twWs_Create: Error creating BSD socket to b
e used for the websocket
[ERROR] 2018-10-19 13:06:00,849 SDK: twApi_Initialize: Error creating websocket
structure, retrying

 

 

Any ideas?

Adrian

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to connect EMS to ThingWorx Composer without SSL

I have a config file that works. Problem now solved:

{
  "ws_servers": [{
    "host": "192.168.1.170",
    "port": 80
  }],
  "appKey": "f9efc9d8-1836-4a44-a8cb-1cb599bd4a49",
  "logger": {
    "level": "DEBUG"
  },
  "certificates": {
    "validate": false,
    "allow_self_signed": true
  },
  "ws_connection": {
    "encryption": "none",
    "verbose": true
  },
  "http_server" : {
        "host": "localhost",
        "port": 8084,    
        "ssl": false,
        "content_read_timeout": 20000,
    "authenticate": false
  }
}

15 REPLIES 15

Re: How to connect EMS to ThingWorx Composer without SSL

Hello.

 

If you just try connecting to tomcat (not ThingWorx) are you able to? And that is on port 8080, yes?

 

 

Thank you for using our community.

 

-- Craig A.

Re: How to connect EMS to ThingWorx Composer without SSL

Hi Craig

Well, I will try to respond correctly here. To be  honest, I did not install our Thingworx server, so don't know that much about it. I will also admit I just chose port 8080 in an attempt to solve the problem. I am not purposely trying to connect to tomcat, if that listens on port 8080. I just want a WS connection for EMS.

 

At any rate, if I try to connect to port 8080 in a browser on my ems machine, it fails. I hope that answers your question.

 

If I try another port (eg port 81), I get this error:

 

[WARN ] 2018-10-19 13:28:07,634 SDK: SDK Version: 2.0.4
[WARN ] 2018-10-19 13:28:07,634 SDK: TLS Library: OpenSSL
[WARN ] 2018-10-19 13:28:07,634 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-10-19 13:28:07,634 SDK: FIPS Capable
[DEBUG] 2018-10-19 13:28:07,634 SDK: twWs_Create: Initializing Websocket Client
for http://192.168.1.170:80//Thingworx/WS
[DEBUG] 2018-10-19 13:28:07,634 SDK: twTlsClient_Create: Initializing TLS Client

[TRACE] 2018-10-19 13:28:07,635 SDK: twSocket_Close: closing socket: 0, socket i
nfo - host: http://192.168.1.170, port: 80, proxyHost: NULL, proxyPort: 0, state
: 0
[DEBUG] 2018-10-19 13:28:07,635 SDK: twTlsClient_Close: Disconnecting from serve
r
[ERROR] 2018-10-19 13:28:07,635 SDK: twWs_Create: Error creating BSD socket to b
e used for the websocket
[ERROR] 2018-10-19 13:28:07,635 SDK: twApi_Initialize: Error creating websocket
structure, retrying
[FORCE] 2018-10-19 13:28:07,780 httpServer: starting http server port=81
[DEBUG] 2018-10-19 13:28:07,785 httpServer: http server bound to port=81.
[DEBUG] 2018-10-19 13:28:12,636 SDK: twWs_Create: Initializing Websocket Client
for http://192.168.1.170:80//Thingworx/WS
[DEBUG] 2018-10-19 13:28:12,636 SDK: twTlsClient_Create: Initializing TLS Client

[TRACE] 2018-10-19 13:28:12,636 SDK: twSocket_Close: closing socket: 0, socket i
nfo - host: http://192.168.1.170, port: 80, proxyHost: NULL, proxyPort: 0, state
: 0
[DEBUG] 2018-10-19 13:28:12,636 SDK: twTlsClient_Close: Disconnecting from serve
r
[ERROR] 2018-10-19 13:28:12,636 SDK: twWs_Create: Error creating BSD socket to b
e used for the websocket
[ERROR] 2018-10-19 13:28:12,636 SDK: twApi_Initialize: Error creating websocket
structure, retrying

Re: How to connect EMS to ThingWorx Composer without SSL

Let's try the simple things first; are there any proxy servers or firewalls that might be interfering with communications on those ports?

 

 

-- Craig A.

Re: How to connect EMS to ThingWorx Composer without SSL

The machines are on the same subnet, so I would say there is no firewall or proxy between them


Adrian

Re: How to connect EMS to ThingWorx Composer without SSL

Understood. Which version of the EMS is this? And the SDK version in use? I find instances of similar errors that have reportedly been fixed in later versions. Let's make sure you have those versions.

 

Thanks,

 

-- Craig A.

Re: How to connect EMS to ThingWorx Composer without SSL

I got the ems from this:

MED-61060-CD-054_F000_Microserver-Windows-x86-32-openssl-5-4-0-114

The Thingworx platform appears to be version 8.

Not sure about the SDK.

Re: How to connect EMS to ThingWorx Composer without SSL

You said:

"if I try to connect to port 8080 in a browser on my ems machine, it fails"

Have you been able to successfully browse to your Thingworx instance? If so, what is the URL you used? The EMS will be able to connect at the same IP and port you used to browse to Thingworx.

If you can browse to Thingworx with:

http://192.168.1.170/Thingworx

Use these settings for the EMS: 

"host": "192.168.1.170",
"port": "80"

If you can browse to Thingworx with:

(note the extra s) https://192.168.1.170/Thingworx

Use these settings for the EMS:

"host": "192.168.1.170",
"port": "443"

 

Also be sure to delete the .booted file between changes to your config.json file so you are not fooled by a syntax errors in your config file causing the EMS to use the last successfully parsed config file.

 

The config file below can be used as a template to connect with the free 30 day trial instances available at developer.thingworx.com

 

 

{
  "ws_servers": [{
  "host": "pp-18090513391s.devportal.ptc.io",
  "port": 443
}],
"appKey": "981b0d67-da01****-8007-01b9c30260b6",

"logger": {
   "level":"DEBUG"
},

"ws_connection": {
  "encryption": "ssl",
  "verbose": true
},

"http_server": {

  "ssl": false,
  "authenticate": false
},

"certificates": {
"validate": false,
"allow_self_signed": true
}

}

Re: How to connect EMS to ThingWorx Composer without SSL

Hi

 

The error has changed and it looks like it is going further, but still not to the end.

 

I can browse to Thingworx using the http url (not https). So I use port 80.


Following your suggestions, this is my config file

 

{
    "ws_servers":    [{
            "host":    "192.168.1.170",
            "port":    80
        }],
    "appKey":    "ad2d631b-d6fe-45f0-a892-6dbc500fd339",
    "logger":   {
        "level":    "DEBUG",
"publish_directory":"logs"
    },
    "certificates": {
        "validate": false        
    },
    "http_server" : {
        
        "ssl" : false,
"authenticate": false        
    }
}

 

There is no config.booted file, so that's okay

 

The debug trace below makes sense right up to near the end where it says this:

[DEBUG] 2018-10-19 16:39:16,384 SDK: twTlsClient_Reconnect: Re-establishing SSL
context

 

Why is it trying to establish SSL?

 

This is the latest debug trace.

[FORCE] 2018-10-19 16:39:16,248 wsems: Initializing EMS ....
[FORCE] 2018-10-19 16:39:16,248 main: Using config file C:\EMS\microserver\etc\c
onfig.json
[INFO ] 2018-10-19 16:39:16,248 wsems: Creating the WsEms proxy.
[INFO ] 2018-10-19 16:39:16,248 wsems: Starting HTTP Server.
[INFO ] 2018-10-19 16:39:16,249 Main: Using custom certificate and private key f
or HTTP Server
[WARN ] 2018-10-19 16:39:16,249 Main: Encryption is disabled on HTTP Server.
[WARN ] 2018-10-19 16:39:16,249 Main: Authentication is disabled on the HTTP Ser
ver.
[INFO ] 2018-10-19 16:39:16,249 wsems: Initializing the ThingWorx REST interface
.
[INFO ] 2018-10-19 16:39:16,249 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2018-10-19 16:39:16,249 wsEmsProxy::initialize: Encryption is enabled on
 Web Socket connection.
[WARN ] 2018-10-19 16:39:16,249 SDK: SDK Version: 2.0.4
[WARN ] 2018-10-19 16:39:16,249 SDK: TLS Library: OpenSSL
[WARN ] 2018-10-19 16:39:16,249 SDK: TLS Library Version: 1.0.2l
[WARN ] 2018-10-19 16:39:16,249 SDK: FIPS Capable
[DEBUG] 2018-10-19 16:39:16,249 SDK: twWs_Create: Initializing Websocket Client
for 192.168.1.170:80//Thingworx/WS
[DEBUG] 2018-10-19 16:39:16,249 SDK: twTlsClient_Create: Initializing TLS Client

[FORCE] 2018-10-19 16:39:16,252 httpServer: starting http server port=8000
[DEBUG] 2018-10-19 16:39:16,255 httpServer: http server bound to port=8000.

192.168.1.170:80-->[DEBUG] 2018-10-19 16:39:16,306 SDK: twApi_Initialize: Websoc
ket Established after 0 tries
[DEBUG] 2018-10-19 16:39:16,307 SDK: subscribedPropsMgr_Initialize: Initializing
 subscribed properties manager
[INFO ] 2018-10-19 16:39:16,307 WsProxy::initialize: EMS Version 5.4.0.114
[INFO ] 2018-10-19 16:39:16,307 WsProxy::initialize: twApi singleton initialized

[WARN ] 2018-10-19 16:39:16,307 WsProxy::initialize: Certificate validation is d
isabled.
[DEBUG] 2018-10-19 16:39:16,307 jsonConfigurator::getJsonEntity: Key validation_
criteria not found
[DEBUG] 2018-10-19 16:39:16,307 jsonConfigurator::getJsonEntity: Parent file not
 found
[DEBUG] 2018-10-19 16:39:16,307 SDK: twTunnelManager_Create: Tunnel Manager sing
leton already exists
[ERROR] 2018-10-19 16:39:16,307 SDK: twMap_Add: parse function returned null.
[DEBUG] 2018-10-19 16:39:16,307 jsonConfigurator::getJsonEntity: Key auto_bind n
ot found
[INFO ] 2018-10-19 16:39:16,307 wsEmsProxy::initialize: Initialization complete!

[INFO ] 2018-10-19 16:39:16,308 wsems: Starting the connection.
[DEBUG] 2018-10-19 16:39:16,384 SDK: twTlsClient_Reconnect: Re-establishing SSL
context
[DEBUG] 2018-10-19 16:39:16,385 SDK: twTlsClient_Connect: Connecting to server
[ERROR] 2018-10-19 16:39:16,386 SDK: TW_NEW_SSL_CLIENT: SSL handshake error. Err
or: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.
[ERROR] 2018-10-19 16:39:16,386 SDK: Error intializing SSL connection
[ERROR] 2018-10-19 16:39:16,386 SDK: twWs_Connect: Error restarting socket.  Err
or 0

 

 

Re: How to connect EMS to ThingWorx Composer without SSL

The EMS will connect to the platform using SSL by default. You need to add this to the config:

 

"ws_connection": {
  "encryption": "none"
}

 

EMS encryption configuration