private void resetTimeout() {
        assertLocked();
        
        clearTimeout();

        // If there are no exchanges waiting, there's nothing to time out.
        if(exchanges.size() == 0)
            return;

        // We should always receive a response within the wait period.
        int timeout;
        if(cmParams == null) {
            // Before we receive the session creation response, assign the requested wait time
            // as the timeout.
            timeout = cfg.getWaitTime() * 1000;
        } else {
            timeout = cmParams.getWait().getValue() * 1000;
        }
        
        // Increase the enforced timeout above the expected timeout, to allow for latency.
        timeout = timeout * 3 / 2;

        // If the timeout is zero, we're effectively in polling mode and the server will
        // reply as soon as possible.  Set a default timeout.
        if(timeout == 0)
            timeout = 60*1000;

        try {
            Runnable runnable = new Runnable() {
                public void run() { connectionLost(new BOSHException("Connection timed out")); }
            };
            
            timeoutFuture = schedExec.schedule(runnable, timeout, TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException rex) {
            LOG.log(Level.FINEST, "Could not schedule empty request", rex);
        }
    }