Class HttpSessionManager


  • public class HttpSessionManager
    extends Object
    Manages sessions for all users connecting to Openfire using the HTTP binding protocol, XEP-0124.
    • Field Detail

      • MAX_POOL_SIZE

        public static SystemProperty<Integer> MAX_POOL_SIZE
        ` Maximum number of threads used to process incoming BOSH data. Defaults to the same amount of threads as what's used for non-BOSH/TCP-connected XMPP clients.
      • MIN_POOL_SIZE

        public static final SystemProperty<Integer> MIN_POOL_SIZE
        Minimum amount of threads used to process incoming BOSH data.
      • POOL_KEEP_ALIVE

        public static SystemProperty<Duration> POOL_KEEP_ALIVE
        Duration that unused, surplus threads that once processed BOSH data are kept alive.
      • SESSION_CLEANUP_INTERVAL

        public static SystemProperty<Duration> SESSION_CLEANUP_INTERVAL
        Interval in which a check is executed that will cleanup unused/inactive BOSH sessions.
      • MAX_PAUSE

        public static SystemProperty<Duration> MAX_PAUSE
        The maximum length of a temporary session pause that a BOSH client MAY request.
      • MAX_WAIT

        public static SystemProperty<Duration> MAX_WAIT
        Returns the longest time that Openfire is allowed to wait before responding to any request during the session. This enables the client to prevent its TCP connection from expiring due to inactivity, as well as to limit the delay before it discovers any network failure.
      • POLLING_INTERVAL

        public static SystemProperty<Duration> POLLING_INTERVAL
        Openfire SHOULD include two additional attributes in the session creation response element, specifying the shortest allowable polling interval and the longest allowable inactivity period (both in seconds). Communication of these parameters enables the client to engage in appropriate behavior (e.g., not sending empty request elements more often than desired, and ensuring that the periods with no requests pending are never too long).
      • MAX_REQUESTS

        public static SystemProperty<Integer> MAX_REQUESTS
        Openfire MAY limit the number of simultaneous requests the client makes with the 'requests' attribute. The RECOMMENDED value is "2". Servers that only support polling behavior MUST prevent clients from making simultaneous requests by setting the 'requests' attribute to a value of "1" (however, polling is NOT RECOMMENDED). In any case, clients MUST NOT make more simultaneous requests than specified by the Openfire.
      • INACTIVITY_TIMEOUT

        public static SystemProperty<Duration> INACTIVITY_TIMEOUT
        Period of time a session has to be idle to be closed. Default is 30 seconds. Sending stanzas to the client is not considered as activity. We are only considering the connection active when the client sends some data or heartbeats (i.e. whitespaces) to the server. The reason for this is that sending data will fail if the connection is closed. And if the thread is blocked while sending data (because the socket is closed) then the clean up thread will close the socket anyway.
      • POLLING_INACTIVITY_TIMEOUT

        public static SystemProperty<Duration> POLLING_INACTIVITY_TIMEOUT
        Period of time a polling session has to be idle to be closed. Default is 60 seconds. Sending stanzas to the client is not considered as activity. We are only considering the connection active when the client sends some data or heartbeats (i.e. whitespaces) to the server. The reason for this is that sending data will fail if the connection is closed. And if the thread is blocked while sending data (because the socket is closed) then the clean up thread will close the socket anyway.
    • Constructor Detail

      • HttpSessionManager

        public HttpSessionManager()
        Creates a new HttpSessionManager instance.
    • Method Detail

      • start

        public void start()
        Starts the services used by the HttpSessionManager. (Re)creates and configures a pooled executor to handle async routing for stanzas with a configurable (through property "xmpp.httpbind.worker.threads") amount of threads; also uses an unbounded task queue and configurable ("xmpp.httpbind.worker.timeout") keep-alive. Note: Apart from the processing threads configured in this class, the server also uses a thread pool to perform the network IO (as configured in (HttpBindManager.HTTP_BIND_THREADS). BOSH installations expecting heavy loads may want to allocate additional threads to this worker pool to ensure timely delivery of inbound packets
      • stop

        public void stop()
        Stops any services and cleans up any resources used by the HttpSessionManager.
      • getSession

        public HttpSession getSession​(String streamID)
        Returns the session related to a stream id.
        Parameters:
        streamID - the stream id to retrieve the session.
        Returns:
        the session related to the provided stream id.
      • createSession

        public HttpSession createSession​(HttpBindBody body,
                                         HttpConnection connection)
                                  throws UnauthorizedException,
                                         HttpBindException,
                                         UnknownHostException
        Creates an HTTP binding session which will allow a user to exchange packets with Openfire.
        Parameters:
        body - the body element that was sent containing the request for a new session.
        connection - the HTTP connection object which abstracts the individual connections to Openfire over the HTTP binding protocol. The initial session creation response is returned to this connection.
        Returns:
        the created HTTP session.
        Throws:
        UnauthorizedException - if the Openfire server is currently in an uninitialized state. Either shutting down or starting up.
        HttpBindException - when there is an internal server error related to the creation of the initial session creation response.
        UnknownHostException - if no IP address for the peer could be found
      • execute

        public void execute​(@Nonnull
                            Runnable runnable)
        Executes a Runnable in the thread pool that is used for processing stanzas received over BOSH.
        Parameters:
        runnable - The task to run