com.lightstreamer.javameclient.midp
Class ConnectionPolicy

java.lang.Object
  extended by com.lightstreamer.javameclient.midp.ConnectionPolicy

public class ConnectionPolicy
extends java.lang.Object

Bean object that contains the configuration settings about connection constraints and fault recovery.


Constructor Summary
ConnectionPolicy()
          Empty constructor
 
Method Summary
 void setBufferedStreamingHandled(boolean bufferedStreamingHandled)
          Setter method that turns on or off the recovery mechanism for streaming connections that appear to be buffered.
 void setIdleTimeout(int idleTimeout)
          Setter method that sets the maximum time the Server is allowed to wait for any data to be sent in response to a polling request, if none has accumulated at request time.
 void setKeepAliveInterval(int keepAliveInterval)
          Setter method that sets the interval between two keepalive packets to be sent by Lightstreamer Server on a stream connection when no actual data is being transmitted.
 void setPollingInterval(int pollingInterval)
          Setter method that sets the polling interval used for poll connections.
 void setRetryTimeout(int retryTimeout)
          Setter method that sets the time the library has to wait, after an unsuccessful streaming or polling connection attempt, before automatically performing a new attempt.
 void setTimeoutForReconnect(int timeoutForReconnect)
          Setter method that sets the time the client Engine, after entering "STALLED" status, is allowed to wait for a keepalive packet or any data on a stream connection, before disconnecting and trying to reconnect to the Server.
 void setTimeoutForStalled(int timeoutForStalled)
          Setter method that sets the extra time the client Engine is allowed to wait when an expected keepalive packet has not been received on a stream connection (and no actual data has arrived), before entering the "STALLED" status.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionPolicy

public ConnectionPolicy()
Empty constructor

Method Detail

setIdleTimeout

public void setIdleTimeout(int idleTimeout)
Setter method that sets the maximum time the Server is allowed to wait for any data to be sent in response to a polling request, if none has accumulated at request time. Setting this time to a nonzero value and the polling interval to zero leads to an "asynchronous polling" behaviour, which, on low data rates, is very similar to the streaming case. Setting this time to zero and the polling interval to a nonzero value, on the other hand, leads to a classical "synchronous polling". Note that the Server may, in some cases, delay the answer for more than the supplied time, to protect itself against a high polling rate or because of bandwidth restrictions. Also, the Server may impose an upper limit on the wait time, in order to be able to check for client-side connection drops.

Parameters:
idleTimeout - The time (in milliseconds) the Server is allowed to wait for data to send upon polling requests (default is 30000).
See Also:
setPollingInterval(int)

setKeepAliveInterval

public void setKeepAliveInterval(int keepAliveInterval)
Setter method that sets the interval between two keepalive packets to be sent by Lightstreamer Server on a stream connection when no actual data is being transmitted. The Server may, however, impose a lower limit on the keepalive interval, in order to protect itself. Also, the Server may impose an upper limit on the keepalive interval, in order to be able to check for client-side connection drops.

Parameters:
keepAliveInterval - The time, expressed in milliseconds, between two keepalive packets. If no value is supplied, the Server will send keepalive packets based on its own configuration
See Also:
setTimeoutForStalled(int), setTimeoutForReconnect(int)

setPollingInterval

public void setPollingInterval(int pollingInterval)
Setter method that sets the polling interval used for poll connections. The client Engine switches from the default streaming mode to polling mode when the client network infrastructure does not allow streaming on HTTP connections. Also, polling mode can be forced by calling any openPollingConnection. The polling interval affects the rate at which polling requests are issued. It is the time between the start of a polling request and the start of the next request. However, if the polling interval expires before the first polling request has returned, then the second polling request is delayed. This may happen, for instance, when the Server delays the answer because of the idle timeout setting. In any case, the polling interval allows for setting an upper limit on the polling frequency. The Server does not impose a lower limit on the client polling interval. However, in some cases, it may protect itself against a high polling rate by delaying its answer. Network limitations and configured bandwidth limits may also lower the polling rate, despite of the client polling interval. The Server may, however, impose an upper limit on the polling interval, in order to be able to promptly detect terminated polling request sequences and discard related session informations.

Parameters:
pollingInterval - The time (in milliseconds) between subsequent polling requests. Zero is a legal value too, meaning that the client Engine will issue a new polling request as soon as a previous one has returned (default is 500).
See Also:
setIdleTimeout(int), LSClient.openPollingConnection(ConnectionInfo, ConnectionListener), LSClient.openPollingConnection(ConnectionInfo, ConnectionListener, ConnectionPolicy)

setTimeoutForReconnect

public void setTimeoutForReconnect(int timeoutForReconnect)
Setter method that sets the time the client Engine, after entering "STALLED" status, is allowed to wait for a keepalive packet or any data on a stream connection, before disconnecting and trying to reconnect to the Server.

Parameters:
timeoutForReconnect - The idle time (in milliseconds) allowed in "STALLED" status before trying to reconnect to the Server (default is 15000).
See Also:
setKeepAliveInterval(int), LSClient.getStatus(), ConnectionListener.onStatusChange(String)

setTimeoutForStalled

public void setTimeoutForStalled(int timeoutForStalled)
Setter method that sets the extra time the client Engine is allowed to wait when an expected keepalive packet has not been received on a stream connection (and no actual data has arrived), before entering the "STALLED" status.

Parameters:
timeoutForStalled - The idle time (in milliseconds) allowed before entering the "STALLED" status (default is 2000).
See Also:
setKeepAliveInterval(int), LSClient.getStatus(), ConnectionListener.onStatusChange(String)

setRetryTimeout

public void setRetryTimeout(int retryTimeout)
Setter method that sets the time the library has to wait, after an unsuccessful streaming or polling connection attempt, before automatically performing a new attempt.

Parameters:
retryTimeout - The time (in milliseconds) to wait (default is 5000).

setBufferedStreamingHandled

public void setBufferedStreamingHandled(boolean bufferedStreamingHandled)
Setter method that turns on or off the recovery mechanism for streaming connections that appear to be buffered.
When the network infrastructure buffers the initial part of the streaming data flow, the Client automatically switches to smart polling mode. Setting this property to true enables the Client to switch-back to streaming mode if the network infrastructure releases the data after the initial buffering.
This recovery mechanism is one of the features of the "Stream-sense" mechanism. It allows a better quality communication channel to be finally established in many cases. But if some intermediate proxy or antivirus buffers the streaming data flow in blocks (that is, not only on the initial part), then the streaming recovery may lead to a worse communication channel, with pauses that may even end up in the client status to become "STALLED".
Note that if single connection mode is used, the streaming connection is closed before the polling attempt is performed. Hence, the recovery is never possible in this case.

Parameters:
bufferedStreamingHandled - true or false, to enable or disable the recovery mechanism for streaming connections that appear to be buffered. (Default value is false)
See Also:
LSClient.useSingleConnection(boolean)