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

Unable to start EMS using wsems

apdams
5-Regular Member

Unable to start EMS using wsems

I have a Thingworx foundation server and am trying to get the EMS started on the same machine, but am having some trouble. These are the steps I have followed:

 

1. I installed MED-61060-CD-053_SP5_Microserver-5-3-4-2383-Win32

2. I configured the config.json file with this (the app key is from my ThingWorx application key

{
 "ws_servers": [{
   "host": "localhost",
   "port": 8080
  }],
 "appKey": "c03fa7e6-ab2f-47bd-9b0b-3d93e2bd03c9"
}
3. When I try to start ems using wsems, I get this output:
[INFO ] 2020-04-17 03:44:43,187 wsems: Using config file: C:\ems\microserver\etc\config.json
[FORCE] 2020-04-17 03:44:43,187 wsems: Starting up ....
[FORCE] 2020-04-17 03:44:43,187 wsems: Initializing EMS ....
[FORCE] 2020-04-17 03:44:43,187 main: Using config file C:\ems\microserver\etc\config.json
[FORCE] 2020-04-17 03:44:43,192 httpServer: starting http server port=8000
localhost:8080-->[ERROR] 2020-04-17 03:44:43,202 httpserver: Server socket error
: Couldn't bind address [*:8000]
[ERROR] 2020-04-17 03:44:44,242 SDK: Error intializing socket connection.  Err = -1
[ERROR] 2020-04-17 03:44:44,242 SDK: twWs_Connect: Error restarting socket.  Error 0
 
What do I do to fix this?

Adrian
1 ACCEPTED SOLUTION

Accepted Solutions
cmorfin
19-Tanzanite
(To:apdams)

Hi @apdams 

 

your config.json does not show anything on port 8000, shouldn't you check the url  http://192.168.1.33:8084/Thingworx/Things/LocalEms/Properties/isConnected  instead ?

 

Christophe

View solution in original post

7 REPLIES 7
apdams
5-Regular Member
(To:apdams)

I think I am making progress, but still not all the way there.

 

I changed my config.json to look like this:

 

{
  "ws_servers": [{
    "host": "192.168.1.33",
    "port": 80
  }],
  "appKey": "c03fa7e6-ab2f-47bd-9b0b-3d93e2bd03c9",
  "logger": {
 "publish_directory": "logs",
    "level": "DEBUG",
    "publish_level": "INFO",
 "max_file_storage": 2000000,
 "auto_flush": true,
 "flush_chunk_size": 16384,
 "buffer_size": 4096
  },
  "ws_connection": {
    "encryption": "none",
    "verbose": true
  },
  "http_server" : {
  "host": "192.168.1.33",
  "port": 8084, 
  "ssl": false,
  "content_read_timeout": 20000,
    "authenticate": false
  },
  "file": {
 "virtual_dirs": [
  {"logs": "logs"},
  {"instruction":"instruction"}
 ],
 "staging_dir": "c:\\ems\\microserver\\staging"
  }
}

 

From the output when I run wsems, I think it is getting further. This is the output:

 

192.168.1.33:80-->[INFO ] 2020-04-17 04:30:08,55 wsems: Using config file: C:\em
s\microserver\etc\config.json
[FORCE] 2020-04-17 04:30:08,55 wsems: Starting up ....
[FORCE] 2020-04-17 04:30:08,55 wsems: Initializing EMS ....
[FORCE] 2020-04-17 04:30:08,55 main: Using config file C:\ems\microserver\etc\co
nfig.json
[INFO ] 2020-04-17 04:30:08,55 wsems: Creating the WsEms proxy.
[INFO ] 2020-04-17 04:30:08,55 wsems: Starting HTTP Server.
[INFO ] 2020-04-17 04:30:08,55 wsems: Initializing the ThingWorx REST interface.
[DEBUG] 2020-04-17 04:30:08,55 SDK: twWs_Create: Initializing Websocket Client f
or 192.168.1.33:80//Thingworx/WS
[DEBUG] 2020-04-17 04:30:08,55 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-04-17 04:30:08,60 SDK: twApi_Initialize: Websocket Established afte
r 0 tries
[DEBUG] 2020-04-17 04:30:08,60 SDK: subscribedPropsMgr_Initialize: Initializing
subscribed properties manager
[DEBUG] 2020-04-17 04:30:08,60 jsonConfigurator::getJsonEntity: Parent certifica
tes not found
[DEBUG] 2020-04-17 04:30:08,60 jsonConfigurator::getJsonEntity: Parent certifica
tes not found
[DEBUG] 2020-04-17 04:30:08,60 SDK: twTunnelManager_Create: Tunnel Manager singl
eton already exists
[DEBUG] 2020-04-17 04:30:08,60 jsonConfigurator::getJsonEntity: Key auto_bind no
t found
[INFO ] 2020-04-17 04:30:08,60 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-04-17 04:30:08,60 wsems: Starting the connection.
[FORCE] 2020-04-17 04:30:08,65 httpServer: starting http server port=8084
[DEBUG] 2020-04-17 04:30:08,65 httpServer: http server bound to port=8084.
[DEBUG] 2020-04-17 04:30:08,85 SDK: twTlsClient_Reconnect: Re-establishing SSL c
ontext
[DEBUG] 2020-04-17 04:30:08,85 SDK: twTlsClient_Connect: Connecting to server
[ERROR] 2020-04-17 04:30:08,85 SDK: twWs_Connect: Error initializing web socket.
  Response code: 404
 
So, question is: how do you solve the Response code: 404 error?

Adrian
slangley
23-Emerald I
(To:apdams)

Hi @apdams.

 

Please check this article to see if it helps.  If you still have issues, please let us know.

 

Regards.

 

--Sharon

apdams
5-Regular Member
(To:slangley)

Hi Sharon

I have (I think) made more progress.

 

This is my latest config file (changed the ws_servers port to 8080):

 

{
  "ws_servers": [{
    "host": "192.168.1.33",
    "port": 8080
  }],
  "appKey": "c03fa7e6-ab2f-47bd-9b0b-3d93e2bd03c9",
  "logger": {
 "publish_directory": "logs",
    "level": "DEBUG",
    "publish_level": "INFO",
 "max_file_storage": 2000000,
 "auto_flush": true,
 "flush_chunk_size": 16384,
 "buffer_size": 4096
  },
  "ws_connection": {
    "encryption": "none",
    "verbose": true
  },
  "http_server" : {
  "host": "192.168.1.33",
  "port": 8084, 
  "ssl": false,
  "content_read_timeout": 20000,
    "authenticate": false
  },
  "certificates":{
 "validate":false,
 "allow_self_signed":true
  },
  "file": {
 "virtual_dirs": [
  {"logs": "logs"},
  {"instruction":"instruction"}
 ],
 "staging_dir": "c:\\ems\\microserver\\staging"
  }
}

 

Now, when I run wsems on the command prompt, it sort of looks like it is working. This is what I get:

 
192.168.1.33:8080-->[INFO ] 2020-04-17 05:28:45,236 wsems: Using config file: C:\ems\microserver\etc\config.json
[FORCE] 2020-04-17 05:28:45,236 wsems: Starting up ....
[FORCE] 2020-04-17 05:28:45,236 wsems: Initializing EMS ....
[FORCE] 2020-04-17 05:28:45,236 main: Using config file C:\ems\microserver\etc\config.json
[INFO ] 2020-04-17 05:28:45,236 wsems: Creating the WsEms proxy.
[INFO ] 2020-04-17 05:28:45,236 wsems: Starting HTTP Server.
[INFO ] 2020-04-17 05:28:45,236 wsems: Initializing the ThingWorx REST interface.
[INFO ] 2020-04-17 05:28:45,241 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-04-17 05:28:45,246 wsems: Starting the connection.
[FORCE] 2020-04-17 05:28:45,246 httpServer: starting http server port=8084
[INFO ] 2020-04-17 05:28:45,271 SDK: twWs_Connect: Websocket connected!
[INFO ] 2020-04-17 05:28:45,306 Main: Succesfully connected.  Saving .booted config file
 
The documentation, however, says that if it starts successfully, "You can tell that WS EMSisrunningand connectedto ThingWorx platformby lookingat the consoleprompt— two plus signs(++) indicatethat it is runningand connected"
 
I don't see any + signs. Does that mean it is not actually started/connected?
 
 
I get this response. Looks like it is not connected!! What am I missing?
 
rows  
0  
isConnected false
datashape  
fieldDefinitions  
isConnected  
name "isConnected"
description ""
baseType "BOOLEAN"
aspects {}
cmorfin
19-Tanzanite
(To:apdams)

Hi @apdams 

 

your config.json does not show anything on port 8000, shouldn't you check the url  http://192.168.1.33:8084/Thingworx/Things/LocalEms/Properties/isConnected  instead ?

 

Christophe

View solution in original post

apdams
5-Regular Member
(To:cmorfin)

i Christophe

 

That was it. 

 

Thanks a lot

Adrian

apdams
5-Regular Member
(To:cmorfin)

Hi Christophe

 

Something very strange has happened. Earlier, my EMS was working and I could query the connected status and it was returning true. I am running the same config file, but now I am getting this in the output and the connected status is false:

 

192.168.1.33:8080-->[INFO ] 2020-04-17 10:21:21,302 wsems: Using config file: C:
\ems\microserver\etc\config.json
[FORCE] 2020-04-17 10:21:21,302 wsems: Starting up ....
[FORCE] 2020-04-17 10:21:21,302 wsems: Initializing EMS ....
[FORCE] 2020-04-17 10:21:21,302 main: Using config file C:\ems\microserver\etc\config.json
[INFO ] 2020-04-17 10:21:21,302 wsems: Creating the WsEms proxy.
[INFO ] 2020-04-17 10:21:21,302 wsems: Starting HTTP Server.
[INFO ] 2020-04-17 10:21:21,302 wsems: Initializing the ThingWorx REST interface.
[INFO ] 2020-04-17 10:21:21,317 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-04-17 10:21:21,317 wsems: Starting the connection.
[FORCE] 2020-04-17 10:21:21,317 httpServer: starting http server port=8084
[INFO ] 2020-04-17 10:21:21,357 SDK: twWs_Connect: Websocket connected!
[WARN ] 2020-04-17 10:21:21,362 SDK: api:sendMessageBlocking: AUTH Message 1 failed.  Code:
[WARN ] 2020-04-17 10:21:26,367 SDK: twWs_Connect: Already connected
[WARN ] 2020-04-17 10:21:26,367 SDK: twWs_Receive: Websocket closed!
[WARN ] 2020-04-17 10:21:26,367 SDK: msgHandlerOnClose: WEBSOCKET CLOSED
[WARN ] 2020-04-17 10:21:26,372 SDK: api:sendMessageBlocking: Receive failed.
[WARN ] 2020-04-17 10:21:26,372 SDK: api:sendMessageBlocking: Message 2 timed ou
t

 

What is happening here?

Adrian

apdams
5-Regular Member
(To:apdams)

Turns out to be the application key had expired.

Suggestion: the error message "api:sendMessageBlocking: Receive failed." is not particularly useful. Something like "application key has expired" would be more useful

Announcements