To summarize, a session can be closed directly by the Web Client Library for internal reasons when:

A) a pending streaming connection is unresponsive for too long (the STALLED case).
This does not mean that no data is coming, because the Server would send keepalive messages in that case.
The related timeouts are configured through setTimeoutForStalled and setTimeoutForReconnect.

B) a reconnection, either during a polling or a streaming session, fails or times out.
The connection timeout cannot be configured.

C) the client is processing updates with increasing delay.
The involved timeout cannot be configured, but the check can be disabled through setSlowingEnabled, though this is not recommended.

The root cause for these issues can be of various types and is usually located on the client machine (high CPU usage, for instance).
In some cases, the cause can be inferred through a check of the Server log (the logging is under improvement to this purpose).