ThingWorx Edge MicroServer (EMS) > Additional Configuration of EMS > Configuring the WebSocket Connection
Configuring the WebSocket Connection
The ws_connection group is used to configure the WebSocket connection between the EMS and the ThingWorx Platform. If the default settings meet your needs, there is no need to include this group in the configuration file.
The code sample below is provided for example purposes only. It shows the group as it appears in the config.json.complete file.
* 
Do not attempt to use config.json.documented as is to run your EMS. It is intended as a reference, not as a valid JSON file that you can use to run EMS. Instead, use config.json.complete. All of the comments have been removed from this file to enable you to run EMS using it.

"ws_connection": {
"encryption" : "ssl ",
"verbose" : false,
"msg_timeout" : 10000,
"ping_rate" : 55000,
"pingpong_timeout" : 10000,
"message_idle_time" : 50000,
"max_msg_size" : 1048576,
"message_chunk_size" : 8192,
"max_messages" : 500,
"connect_timeout" : 10000,
"connect_retry_interval" : 10000,
"max_threads" : 4,
"max_connect_delay" : 10000,
"socket_read_timeout" : 0,
"frame_read_timeout" : 10000,
"ssl_read_timeout" : 500,
"connect_retries" : -1,
"compression" : true
},
* 
As of v.5.4.3 of the EMS, duty-cycle modulation behavior and configuration have changed. The configuration of duty cycle has its own group in the config.json file. The two properties, connect_period and duty_cycle, have been moved from the ws_connection group to the duty_cycle group. A third property, delay_duty_cycle has been added. For details, refer to Configuring Duty Cycle Modulation.
The following table describes properties available to configure the WebSocket connection, in alphabetical order:
Use
To Specify
encryption
Whether SSL/TLS is used for the WebSocket connection. The default value is ssl. To disable SSL/TLS (NOT recommended), set this property to none.
verbose
Whether or not the EMS is in extremely verbose logging mode. The default value is false.
msg_timeout
The time in milliseconds to wait for a response to return from the ThingWorx Platform. The default value is 10000 milliseconds (10 seconds).
ping_rate
The rate in milliseconds to send pings to the ThingWorx Platform. The default value is 55000 milliseconds.
pingpong_timeout
The amount of time in milliseconds to wait for a pong response after sending a ping. A timeout initiates a reconnect. The default value is 10000 milliseconds.
message_idle_time
The time in milliseconds to wait to refer to if messages are being sent before disconnecting for the off time of the duty cycle. The default value is 50000 milliseconds.
max_msg_size
The maximum size, in bytes, of a complete message, even if broken into frames. The default value is 1048576 bytes (1 MB).
message_chunk_size
The maximum size of a chunk — a piece of a large message that has been broken up into chunks. The default value is 8192 bytes.
max_messages
The maximum number of requests that can be waiting for a response at any one time. The default value is 500 requests.
connect_timeout
The maximum number of milliseconds, to wait for a connection to a ThingWorx Platform instance to be established. The default value is 10000 milliseconds (10 seconds).
connect_retry_interval
The number of milliseconds, to wait between attempts to connect to a ThingWorx Platform instance. The default value is 10000 milliseconds (10 seconds).
max_threads
The maximum number of incoming message handler threads to use. The default value is 4.
max_connect_delay
The maximum amount of random delay time, in milliseconds, to wait before connecting. The default value is 10000 milliseconds (10 second delay before connecting).
socket_read_timeout
The maximum amount of time, in milliseconds, to wait for data before timing out. To match the best practices recommendation for transferring large files, the default value is 0 milliseconds.
If your EMS does not transfer large files, consider setting this property to 100 ms. When set to a non-zero value, this property defines how long a process is allowed to wait for data before it must try again. Another process would be allowed to read from the socket between tries. A timeout does not trigger an error. Refer to the Note above for frame_read_timeout.
frame_read_timeout
The maximum amount of time, in milliseconds, to wait for a full SSL/TLS frame during a socket read operation. The default value is 10000 milliseconds. A timeout occurs if the EMS requests something from the ThingWorx Platform and receives no data at all The timeout triggers an error and causes a disconnect.
* 
The difference between socket_read_timeout (described below) and frame_read timeout lies in the scope and context in which these timeouts are used. The socket_read_timeout is used everywhere — in tunnels, e.g. — and anywhere there is a raw socket read. The frame_read timeout is used in one place only — twWs_Receive() and then only after a WebSocket header has been received. After that, there is an expectation that the remainder of the frame described in the header will arrive in a timely manner. This specialized amount of time is the frame_read_timeout.
ssl_read_timeout
The maximum amount of time, in milliseconds, to wait for a full SSL/TLS record during a socket read operation. The default value is 500 milliseconds. A timeout does not trigger an error. This property effectively allows a read to continue after the socket_read_timeout is reached IF a partial amount of the SSL/TLS record is received on the socket before the socket_read_timeout expires.
connect_retries
The number of times to retry the connection when it fails, as an INTEGER. The default value, -1, causes the EMS to retry forever.
compression
As of v.5.4.5, you can specify whether compression is enabled or disabled for websocket connections. By default this property is set to true, meaning that compression is enabled. Set this property to false to disable compression.
Was this helpful?