Configuring Connection Time-Outs and Retries

The channel properties (for JCSMP), or Session properties (for the Java RTO, C, and .Cyberspace APIs), discussed in this section are used to configure a client's beliefs for connecting and reconnecting to Solace PubSub+ effect brokers.

For an example of how these Session backdrop work in relation to i another when a list of potential hosts are provided for client connectedness attempts, see Sample Connect Retry Scenario.

For more information on listing multiple hosts, see Host.

Solace API default values

The default values for connection fourth dimension-outs, retries, and retry wait times differ among the Solace APIs. To discover the default value for one of the properties listed in this section, run across the Solace Messaging APIs documentation for the appropriate API.

Session property values for HA pairs

When using HA redundant issue broker pairs, a neglect-over from one event broker to its mate will typically occur in under 30 seconds; however, applications should effort to reconnect for at least 5 minutes. To allow for a reconnect elapsing of five minutes for HA redundant consequence brokers, set the following session properties to these values:

  • connect retries: 1
  • reconnect retries: 20
  • reconnect retry wait: 3,000 ms
  • connect retries per host: v

Connexion Time-Out

The connection fourth dimension-out holding is the maximum amount of time (in milliseconds) allowed for a Session to establish an initial connection to an event broker.

When a host list is used, the amount of time set for the Connexion Time-Out belongings is applied to each connection attempt to a host. So, for case, if four host entries are listed, a worst-case scenario would exist that an application would have to await for the connectedness time-out to occur for each host entry, times the number of connect attempts, earlier receiving a notice of an established connexion or a connection failure. This wait time is also extended past the Reconnect Retry Wait time that occurs afterwards each unsuccessful attempt to connect to a host.

A connection attempt can terminate quicker if a failure is detected by the socket layer.

Considerations when using JCSMP

When using JCSMP, the following considerations also apply:

  • If the operating system used by the client awarding uses a maximum TCP connect timeout value that is less than the API connect timeout value (ConnectTimeoutInMillis), the operating organisation's maximum TCP connect timeout volition determine when the connection attempt will timeout.
  • If a client can't authenticate with the event broker inside the corporeality of time configured for the read timeout (readTimeoutInMillis) belongings, the Session will be disconnected. If this occurs, y'all can increase the read timeout value.
  • When publishing big JMS messages (90MB or more), the processing fourth dimension may take longer than the default read timeout period of 10s. You can change the read timeout value past using the following command:

    setReadTimeoutInMillis public void setReadTimeoutInMillis(int readTimeoutInMillis)

    Accept a expect at the JCSMP reference guide for more information.

To set a connection Time-Out value

PubSub+ Messaging API

Holding

JCSMP

JCSMPChannelProperties.setConnectTimeoutInMillis()

Java RTO

SessionHandle.Properties.CONNECT_TIMEOUT_MS

C

SOLCLIENT_SESSION_PROP_CONNECT_TIMEOUT_MS

.Internet

SessionProperties.ConnectTimeoutInMsecs

JavaScript and Node.js

solace.SessionProperties.connectTimeoutInMsecs

Connect Retries

The Connect Retries belongings sets the number of times to retry to establish an initial connection for a Session to a host event banker.

The valid range for the Connect Retries property is –1 or greater. A value of –1 ways retry forever; a value of 0 means no automatic connection retries (that is, try once and give up).

If a host list is used, the API attempts to establish a connection to the get-go listed event broker. If that effort fails, the API waits for the amount of fourth dimension ready for the Reconnect Retry Wait property before attempting another connectedness to either the aforementioned host. (The value of Connect Retries Per Host property sets the number times to attempt to connect to i host before moving to the side by side listed host.) The API attempts to connect to the host entries sequentially in the order they are listed.

If the Connect Retries belongings is greater than 0, the API can retry a connection attempt at the showtime of the host list if no connexion could be established to any of the entries in the list. Each time the API works through the host list without establishing a connectedness is considered a connect retry. For example, for a Connect Retries value of 2, the API could mayhap piece of work through all of the listed hosts without connecting to them three times: ane time through for the initial connect attempt, then 2 times through for each connect retry. Each connect retry begins with the start host listed.

For JCSMP

The connect retries value refers to the total number of connection attempts, including the initial connectedness endeavour. For example, setting the connect retries value to 3 in JCSMP results in a maximum of 3 connection attempts: the initial attempt and ii retries.

For the Java RTO, C, and .NET APIs

The connect retries value refers strictly to the total number of connectedness retries and doesn't include the initial connection attempt. For example, setting the connect retries value to 3 in the Java RTO, C, or .Internet APIs results in a maximum of 4 connection attempts: the initial effort and three retries.

To set the number of Connect Retries

PubSub+ Messaging API

Property

JCSMP

JCSMPChannelProperties.setConnectRetries(...)

Java RTO

SessionHandle.Properties.CONNECT_RETRIES

C

SOLCLIENT_SESSION_PROP_CONNECT_RETRIES

.NET

SessionProperties.ConnectRetries

JavaScript and Node.js

solace.SessionProperties.connectRetries

Reconnect Retries

The Reconnect Retries property sets the number of times to try to reconnect to a host after a connected Session goes down.

The valid range is greater than or equal to –1. A value of –1 means retry forever; a value of 0 means no automatic reconnection attempts.

If a host list is used, this property sets the number of times the API will traverse the host list in an effort to reconnect to ane of the hosts in the listing. That is, if the API cannot connect to the first consequence broker on the list (that is, the preferred event broker), it attempts to connect to the next listed event broker, and and then on. The API attempts to connect to each host for the number of times ready for the Connect Retries Per Host property earlier attempting to connect to the next host.

Afterwards each unsuccessful connection attempt, the API waits for the corporeality of time set for the Reconnect Retry Look belongings to elapse before attempting to connect to the aforementioned host, the next listed host, or, afterward all of the listed hosts have been attempted, to the offset host on the list again.

Multiple reconnects should exist specified when the Session is working with a host for which consequence broker redundancy has been enabled (that is, the IP address listed equally a host is used by a pair of redundant effect brokers). Disabling reconnect retries could affect activity switches that might occur when active/active redundancy is used and could cause service disruptions. For example, in a neglect-over scenario, if no reconnect retries are enabled, a connection attempt cannot be made to the redundant upshot broker.

Solace recommends that yous set the Reconnect Retries value to the maximum number of attempts that y'all are willing to endeavour before moving to an alternative error treatment approach. In this example you may have encountered an event that cannot be resolved by reconnecting the session to the host, and further consideration is required. For instance, investigating an upshot with the event broker.

JCSMP

An automatic reconnect frequency limit is used to prevent a client from reconnecting more than ten times (default) within iv seconds. If the effect broker permits the replacement of indistinguishable client connections during authentication, when multiple clients with the aforementioned client user name are used, they could enter a cycle where ane client connects and so is disconnected when another client connects. If these clients have a not-zippo Reconnect Retries value, each time one disconnected client successfully reconnects, it disconnects another continued client. The automated reconnect frequency limit ensures that this client connect/reconnect bike does non occur indefinitely.

For information on how to enable the replacement of duplicate client connections during authentication, see Configuring the Connection Beliefs for Indistinguishable Clients .

To set the number of Reconnect Retries

PubSub+ Messaging API

Property

JCSMP

JCSMPChannelProperties.setReconnectRetries(...)

Java RTO

SessionHandle.Backdrop.RECONNECT_RETRIES

C

SOLCLIENT_SESSION_PROP_RECONNECT_RETRIES

.NET

SessionProperties.ReconnectRetries

JavaScript and Node.js

solace.SessionPropertiess.reconnectRetries

Reconnect Retry Await

The Reconnect Retry Wait property sets the fourth dimension to wait (in milliseconds) after an unsuccessful attempt to reconnect to the aforementioned host that the client was connected to. After this fourth dimension expires, some other reconnect try tin can be made. The valid range for the Reconnect Retry Wait property is 1 or greater.

If the API works through all of the entries in the host list without establishing a connection, and a connect retry is permitted because the Connect Retry belongings is greater than 0, the API waits for the amount of time set for the Reconnect Retry Await belongings before retrying to connect to the showtime host in the host list.

To set the Reconnect Retry Await Times

PubSub+ Messaging API

Belongings

JCSMP

JCSMPChannelProperties.setReconnectRetryWaitInMillis()

Coffee RTO

SessionHandle.Properties.RETRY_WAIT_MS

C

SOLCLIENT_SESSION_PROP_RECONNECT_RETRY_WAIT_MS

.Cyberspace

SessionProperties.
ReconnectRetriesWaitInMsecs

JavaScript and Node.js

solace.SessionProperties.reconnectRetryWaitInMsecs

Connect Retries Per Host

When using a host listing, the Connect Retries Per Host property sets how many times to try to connect or reconnect the Session to i host before moving to the next host in the list.

A value of 0 ways brand a unmarried connection or reconnection attempt (that is, 0 retries). A value of –1 means attempt an infinite number of connect or reconnect retries (in this case, the API but tries to connect or reconnect to starting time host listed).

If a connect or reconnect attempt to a host is not successful, the API must wait for the amount of fourth dimension ready for the Reconnect Retry Wait property, before making another connect or reconnect effort.

Application disconnection and Guaranteed messages

If a client application gets asunder, the API volition endeavor to reconnect to the event broker it was continued to, and if that fails it will endeavor to reconnect to the next listed host, and then on. If the application had published Guaranteed messages prior to being reconnected to a new host, the new host volition not have the required Guaranteed messaging publisher state to agree with the API on which messages were last received / acknowledged. Therefore, the API will reset the publisher flow state, renumber and resend any unacknowledged letters.

If the new host was configured as a Replication mate of the original host, resending letters may create duplicates because the original messages may have been successfully delivered to the mate even though from the API'southward perspective they were unacknowledged. In this example, it is upwards to the receiving application to resolve this duplication in an advisable mode.
For API versions prior to 7.ane.2, if a reconnect to a unlike host occurred after publishing Guaranteed messages, the API would close the newly created session and raise a session event—the application was responsible for reconnecting and resending any unacknowledged published messages. To use this legacy behavior, you must alter the reconnect fail action channel or session property to the appropriate non-default value. For more information, come across Solace Messaging APIs.

To set the Connect Retries Per Host

PubSub+ Messaging API

Belongings

JCSMP

JCSMPChannelProperties.setConnectRetriesPerHost(...)

Java RTO

SessionHandle.PROPERTIES.CONNECT_RETRIES_
PER_HOST

C

SOLCLIENT_SESSION_PROP_CONNECT_RETRIES_PER_
HOST

.NET

SessionProperties.ConnectRetriesPerHost

JavaScript and Node.js

solace.SessionProperties.connectRetriesPerHost

Sample Connect Retry Scenario

The effigy below shows how the Connect Try and Retry properties can affect a client's connectedness endeavour behavior when a host listing is used. For demonstration purposes, this example shows the worst instance scenario where all potential connexion attempts are unsuccessful.

The Connect Retries property behaves differently co-ordinate to which messaging API is used. Run into Connect Retries for more information.

Connexion Attempt Behavior When Using a Host List

Each time the API works through all of the entries in the host listing without establishing a connection is considered a Connect Try or Retry. So, if a connection to i of the listed hosts isn't established during the initial Connect Try, a Connect Retry value of 2 means that API can work through the host list two more than times (once more, each listed host tin exist attempted upwardly to 2 times for each Connect Retry). Each Connect Retry begins with the get-go host and works through the entries in the society in which they are listed.

Therefore, in the worst case scenario, the API could perhaps piece of work through the host list three times without making a connection to a host (one time through for the initial Connect Try, and then 2 times through for the Connect Retries), and because the Connect Retry Per Host value of 2 causes each host to exist attempted twice, a maximum of 32 connection attempts can be fabricated.