Skip to content

Screenshot Downloads ​

Butler SOS can download screenshot URLs emitted by Audit.qs and save the resulting image files to enabled destinations.

This page documents the runtime contract for screenshot downloads: authentication, user identity parsing, redirect handling, session reuse, and failure behavior.

Scope ​

This page applies to audit events of type screenshot.url.received.

It focuses on the screenshot-specific configuration under Butler-SOS.auditEvents.destination.screenshots.

Authentication Modes ​

Screenshot downloads support the same general download flow regardless of destination, but the authentication behavior depends on the configured mode.

auth.mode: userTicket ​

Use userTicket when:

  • Audit.qs runs against Qlik Sense Enterprise on Windows or another client-managed deployment
  • payload.context.user contains a parseable Qlik identity
  • Butler SOS has Qlik client certificates for mutual TLS to QPS
  • The screenshot URL uses the same Qlik route that the browser used to render the image

Do not use userTicket for Qlik Cloud-only identities that resolve to email addresses without userDirectory and userId.

auth.mode: qpsTicket ​

Fixed QPS ticket mode follows the same redirect and session-cache rules described on this page where noted, but it does not derive the ticket from the event user identity.

Minimal Configuration ​

yaml
Butler-SOS:
  auditEvents:
    destination:
      screenshots:
        enable: true
        allowedImageDownloadHosts:
          - qlik.example.com
          - qlik-proxy.example.com
        auth:
          mode: userTicket
          qps:
            host: qlik.example.com
            port: 4243
            ticketTimeoutMs: 5000
          sessionCache:
            enable: true
            ttlSeconds: 120
            maxEntries: 100

User Identity Contract ​

For userTicket, Butler SOS expects the full Qlik identity in payload.context.user.

Example event fragment:

json
{
  "payload": {
    "context": {
      "user": "UserDirectory=LAB; UserId=john.doe"
    },
    "event": {
      "screenshotUrl": "https://qlik.example.com/analytics/tempcontent/abc/screenshot.png"
    }
  }
}

Butler SOS keeps these values distinct:

FieldMeaning
userFull identity string from Qlik Sense
userDirectoryParsed directory component
userIdParsed user ID component

If userTicket cannot parse the user identity, Butler SOS logs a warning and skips that screenshot download. It does not fall back to fixed qpsTicket credentials.

Virtual Proxy Derivation ​

For userTicket, Butler SOS derives the QPS virtual proxy from the screenshot URL path.

Examples:

  • https://qlik.example.com/analytics/tempcontent/abc/screenshot.png maps to /qps/analytics/ticket
  • https://qlik.example.com/tempcontent/abc/screenshot.png maps to /qps/ticket

The original screenshot URL is the authoritative source for route selection.

Redirect Handling And Allowed Hosts ​

Butler SOS handles screenshot redirects manually. It does not let the HTTP client follow redirects automatically.

Redirects are followed only when all of the following are true:

  • The response status is 301, 302, 303, 307, or 308
  • A valid Location header is present
  • The redirected URL resolves to http: or https:
  • Every hostname in the redirect chain is listed in allowedImageDownloadHosts
  • The redirect chain does not exceed the configured redirect limit

Allowed Host Rule ​

The original screenshot host and every redirected hostname must appear in allowedImageDownloadHosts.

Example:

text
https://qlik.example.com/screenshot.png
  -> https://proxy.example.com/redirected/screenshot.png
  -> https://node1.example.com/tempcontent/screenshot.png

Required configuration:

yaml
Butler-SOS:
  auditEvents:
    destination:
      screenshots:
        allowedImageDownloadHosts:
          - qlik.example.com
          - proxy.example.com
          - node1.example.com

Use hostnames only. Do not include schemes, ports, paths, or full URLs.

If a redirect is relative, the hostname does not change and no extra host entry is needed.

Session Cache ​

auth.sessionCache works with both userTicket and qpsTicket.

Butler SOS does not cache one-use QPS tickets. It caches only the redeemed Qlik session cookie returned by the screenshot download flow.

On cache hit, Butler SOS sends the cached session cookie directly. On cache miss, it requests a fresh ticket and stores the returned session cookie when caching is enabled.

Cache entries are separated by:

  • auth mode
  • QPS host and port
  • virtual proxy
  • user directory
  • user ID

For userTicket, this means each end user gets an isolated cached session.

If Qlik Sense rejects a cached session with 401 or 403, Butler SOS removes that session from memory and retries with a fresh QPS ticket.

Settings ​

Session caching lives under Butler-SOS.auditEvents.destination.screenshots.auth.sessionCache:

yaml
Butler-SOS:
    auditEvents:
        destination:
            screenshots:
                auth:
                    mode: userTicket   # Caching applies to userTicket and qpsTicket only
                    sessionCache:
                        enable: true   # Default false
                        ttlSeconds: 120  # Default 120. Minimum 1.
                        maxEntries: 100  # Default 100. Minimum 1.
KeyDefaultDescription
enablefalseWhen true, a Qlik Sense session obtained for one screenshot can be reused for later screenshots for the same user and virtual proxy.
ttlSeconds120How long a cached session may be reused, in seconds. Must be between 1 and 2147483 (about 24 days). Decimal values are allowed.
maxEntries100Maximum number of cached sessions held at once. Must be a whole number of at least 1.

Session caching only applies when the screenshot authentication mode is userTicket or qpsTicket. It is ignored when the mode is none.

Fractional ttlSeconds values ​

Changed in 15.1.0

Before Butler SOS 15.1.0, certain decimal ttlSeconds values stopped screenshot capture completely, and ttlSeconds had no upper limit.

ttlSeconds accepts decimal values. Certain values used to stop screenshot capture completely.

The problem ​

ttlSeconds accepts decimal values, so 1.5 (one and a half seconds) has always been a valid setting. Internally the value is converted from seconds to milliseconds, and the component that enforces the expiry time only accepts whole milliseconds.

Not every decimal value converts to a whole number of milliseconds, and such values were rejected outright.

The obvious case is a setting with more precision than a millisecond: 1.0005 seconds is 1000.5 milliseconds, which is not a whole number.

The more common case is far less obvious. Computers store decimal numbers in binary, and most decimal fractions have no exact binary equivalent — in the same way that one third has no exact decimal form. 16.1 cannot be stored exactly, so multiplying it by 1000 gives 16100.000000000002 rather than 16100, and that is not a whole number either.

This is why the problem could not be predicted from how a value was written. Perfectly ordinary-looking settings were affected: 16.1, 32.2, 32.3, 32.7 and 64.1 all failed, while 1.5, 2.25 and 120.125 all worked. There is no rule of thumb — such as counting decimal places — that separates the two groups. Whole numbers like 60, 120 and 300 were always safe.

The effect was severe and easy to misread:

  • Every screenshot download attempt failed, including all automatic retries.
  • No screenshots were captured at all for as long as the setting was in place.
  • Butler SOS itself kept running normally, and everything unrelated to screenshots was unaffected, so the problem looked like a Qlik Sense connectivity issue rather than a configuration issue.

The error text written to the Butler SOS log for each failed attempt was:

ttl must be a positive integer if specified

That message does not mention ttlSeconds, session caching, or screenshots, which made the cause very hard to find.

What has changed ​

Butler SOS now converts ttlSeconds to the nearest whole millisecond before applying it.

  • ttlSeconds: 16.1 is treated as 16100 milliseconds instead of failing.
  • ttlSeconds: 1.0005 is treated as 1001 milliseconds instead of failing.
  • A value so small that it would round down to zero is treated as 1 millisecond, so a cached session can never be given an unlimited lifetime by accident.

Values that already worked are unchanged: 120 still means exactly 120 seconds, and 1.5 still means exactly 1500 milliseconds. No configuration change is required when upgrading, and no setting has been renamed or removed, and no default has changed.

A new upper limit on ttlSeconds ​

ttlSeconds now has a maximum of 2147483 seconds, about 24 days. This is the longest expiry that Butler SOS can actually schedule.

Previously the setting had no upper limit, and a larger value did not do what it looked like it did. The expiry could not be scheduled, so cached sessions never expired at all, and Butler SOS spent a continuous slice of CPU rescheduling the expiry it could not perform, writing a warning to the log each time.

A value above the maximum is now rejected when Butler SOS starts, with a message naming the setting, rather than being accepted and quietly misbehaving. If your configuration contains a ttlSeconds larger than 2147483, Butler SOS will refuse to start after upgrading until you lower it. Such a value was never working as intended, so lowering it to a realistic session lifetime is the correct fix in any case. Defaults and all realistic values are far below this limit, so almost no installation is affected.

What to do ​

If screenshot capture has been failing in your environment and the log contains ttl must be a positive integer if specified, the cause was this issue. After upgrading, screenshot capture resumes with no configuration change.

Check whether your ttlSeconds is larger than 2147483, since that value now prevents Butler SOS from starting. Lower it to a realistic session lifetime.

Otherwise, if you would rather not rely on rounding, set ttlSeconds to a whole number of seconds. For most environments a value between 60 and 300 seconds is a reasonable choice: long enough that a burst of screenshots reuses one Qlik Sense session, short enough that a session is not held long after it stops being useful.

Redirects With Qlik Session Cookies ​

When the first request redeems a QPS ticket, Qlik Sense may return a session cookie such as X-Qlik-Session-*.

If that happens on a redirect response, Butler SOS carries that cookie forward to the next allowed hop. This matters because QPS tickets are single-use and should not be reused on the redirected request.

For userTicket, redirect targets are checked against allowedImageDownloadHosts, but redirect targets are not used to choose a different QPS ticket endpoint.

Runtime Flow ​

  1. Butler SOS receives a screenshot.url.received event.
  2. It parses payload.context.user when auth.mode is userTicket.
  3. It checks the session cache for the current auth mode, virtual proxy, and user.
  4. On cache miss, it requests a QPS ticket over mutual TLS.
  5. It redeems that ticket against the screenshot URL or sends the cached session cookie.
  6. It validates each redirect hop before continuing.
  7. It downloads the screenshot and writes the file to enabled destinations.
  8. It stores or invalidates the resulting Qlik session cookie according to cache behavior.

Troubleshooting ​

If screenshot downloads fail, check these first:

  • The original screenshot hostname is listed in allowedImageDownloadHosts
  • All redirect hosts are listed in allowedImageDownloadHosts
  • The user identity in payload.context.user is parseable
  • Butler SOS has working Qlik client certificates for QPS access
  • The screenshot URL uses the expected virtual proxy path

Common warning patterns:

  • redirect blocked reason=host-not-allowed: add the redirected hostname if it is a legitimate Qlik or reverse-proxy host
  • user parsing warnings in userTicket mode: verify that Audit.qs sends a full Qlik identity string
  • repeated 401 or 403 after cache hits: inspect session expiry and QPS connectivity
  • ttl must be a positive integer if specified on every download (Butler SOS before 15.1.0): see Fractional ttlSeconds values

Released under the MIT License.