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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

[EMS] Unable to re-establish WS connections after network disconnection

???-31
7-Bedrock

[EMS] Unable to re-establish WS connections after network disconnection

Hi, all

I have succeeded in connecting to TW platform from EMS, sending/receiving data, executing services etc..

However, once the devices are disconnected from the network,

EMS continues to fail to re-establish the connection to TW despite a network restoration.

Following are log and config.json.

Are there any setting items yet to be set?

Regards,

S.Yamabe

log

{"level":"FORCE","timestamp":"2016-02-16T15:06:10,393","origin":"C:\EMSProject_Basic\wsems.exe","content":"Starting up ...."}

{"level":"FORCE","timestamp":"2016-02-16T15:06:10,451","origin":"C:\EMSProject_Basic\wsems.exe","content":"Initializing EMS ...."}

{"level":"FORCE","timestamp":"2016-02-16T15:06:10,476","origin":"main","content":"Using config file C:\\EMSProject_Basic\\etc\\config.json"}

{"level":"FORCE","timestamp":"2016-02-16T15:06:10,501","origin":"httpServer","content":"starting http server port=8000"}

{"level":"AUDIT","timestamp":"2016-02-16T15:06:10,534","origin":"SDK","content":"twWs_Connect: Websocket connected!"}

== DISCONNECTED FROM NETWORK ==

{"level":"WARN","timestamp":"2016-02-16T15:07:15,814","origin":"SDK","content":"apiThread: Did not receive pong in time"}

{"level":"WARN","timestamp":"2016-02-16T15:07:15,877","origin":"SDK","content":"msgHandlerOnClose: WEBSOCKET CLOSED"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:15,901","origin":"SDK","content":"Error intializing socket connection.  Err = -1"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:15,926","origin":"SDK","content":"twWs_Connect: Error restarting socket.  Error 0"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:20,828","origin":"SDK","content":"Error intializing socket connection.  Err = -1"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:20,877","origin":"SDK","content":"twWs_Connect: Error restarting socket.  Error 0"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:25,828","origin":"SDK","content":"Error intializing socket connection.  Err = -1"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:25,987","origin":"SDK","content":"twWs_Connect: Error restarting socket.  Error 0"}

== RECONNECTED TO NETWORK ==

{"level":"ERROR","timestamp":"2016-02-16T15:07:30,829","origin":"SDK","content":"Error intializing socket connection.  Err = -1"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:30,894","origin":"SDK","content":"twWs_Connect: Error restarting socket.  Error 0"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:56,835","origin":"SDK","content":"Error intializing socket connection.  Err = -1"}

{"level":"ERROR","timestamp":"2016-02-16T15:07:56,887","origin":"SDK","content":"twWs_Connect: Error restarting socket.  Error 0"}

... continuing same logs ...

config.json

{

  "ws_servers": [{

    "host": "<hostname>",

    "port": 443

  }],

    "appKey": "<appkey>",

  "certificates": {

    "validate": false

  },

  "ws_connection": {

  "encryption": "ssl",

  "verbose": false

  },

  "proxy": {

    "host": "<proxy>",

    "port": <port>,

    "user": "<user>",

    "password": "<pass>"

  },

  "logger": {

    "level": "WARN",

    "publish_directory": "C:/EMS/logs/",

    "publish_level": "WARN",

    "max_file_storage": 2000000,

    "auto_flush": true

  },

  "offline_msg_store": {

    "enabled": true,

    "directory": "C:/EMS/Offline",

    "max_size": 65535

  },

  "file": {

    "buffer_size": 8192,

    "max_file_size": 8000000000,

    "virtual_dirs": [{

    "tw": "c:\\EMS"

  }],

    "staging_dir": "C:\\EMS\\Staging"

  }

}

7 REPLIES 7
Aanjan
12-Amethyst
(To:???-31)

Yamabe, what version of the wsems is this? Also, what proxy is involved? Just to make sure, under your certificate section can you add: "allow_self_signed": true and also set verbose: true under ws_connection and post the complete set of logs?

???-31
7-Bedrock
(To:Aanjan)

Aanjan Ravi,

Thank you for your reply.


Version of WSEMS

I don't know what version of wsems I use, but I re-downloaded it from Device QuickStart Kits  | ThingWorx​ and tried today.

Maybe latest version?

Proxy

In my company, we must connect from intranet to the internet via proxy with authentication.

For this case, EMS is in intra and TW is on the internet, so I have to have proxy setting.

I don't know of (and I couldn't tell) detail because it is managed by Infrastructure department,

but the proxy seems to be built by squid.

Log

I added two settings you specified, and changed log levels to "TRACE"

(because the WARN log output had been exactly the same despite adding two option)

I attach the full log to this post.

???-31
7-Bedrock
(To:???-31)

Additional information.

  • I have downloaded latest "MED-61060-CD-053_M010_MicroServer-5-3-1-1113-Win32" from eSupport and tried, but failed.
  • WITHOUT any proxies, EMS can successfully re-establish connections to the platform by exactly the same scripts.

So it seems to be a problem of proxy..

Does this occur for any of the proxies or on specific conditions?

Regards,

S.Yamabe

Aanjan
12-Amethyst
(To:???-31)

If it is using a reverse proxy, you don't need to add the proxy header section (as anything connecting shouldn't even know there's a proxy involved). Can you check if the proxy server you are using supports websockets?

???-31
7-Bedrock
(To:Aanjan)

Aanjan Ravi worte

Can you check if the proxy server you are using supports websockets?

I will. However, it will take quite a few time and I'm not sure if I can know the detail..

Two things I'm sure of are...

  • We can NOT connect to the platform at all WITHOUT proxy host, username and password.
  • We can establish the WS connection to the platform when wsems.exe starts (first try) WITH proxy settings, and can maintain WS connection unless the network disconnection occurs.
Aanjan
12-Amethyst
(To:???-31)

Regarding your second point, when you have an active connection, can you do file transfers (I'm asking because you've added them in the config.json) or even add the sample/example properties through the luaScriptResource into the platform and check if they function correctly?

???-31
7-Bedrock
(To:Aanjan)

Aanjan Ravi wrote:

Regarding your second point, when you have an active connection, can you do file transfers (I'm asking because you've added them in the config.json) or even add the sample/example properties through the luaScriptResource into the platform and check if they function correctly?

As far as we have a valid connection, we can send files from the repository on the Platform to EMS, and vice versa.

Adding and binding remote properties from LSR through EMS also works and properties are being updated for every scanRate time...

Going off on the subject a bit, we cannot connect to the Platform through proxy by Java SDK at all (with proxy setting items set, of course).

Probably I will post another topic for this problem, but I just wrote it here because it could be any hint.

Announcements


Top Tags