Set timeout for loading external resources

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

If a document contains external resources like images, GroupDocs.Viewer loads them while rendering the document.

In the 19.12 version and earlier, the default timeout was 100 seconds. It may slow rendering when a service that provides external resources is down.

Since the 19.12 version, the default timeout is 30 seconds. Besides that, you can specify the desired timeout using LoadOptions.

This feature is supported for the Word Processing File Formats.

The following code snippet shows how to set a timeout to load external resources:

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
import com.groupdocs.viewer.options.LoadOptions;
// ...

LoadOptions loadOptions = new LoadOptions();
// Specify a timeout.
loadOptions.setResourceLoadingTimeout(500);

// Render a file.
try (Viewer viewer = new Viewer("sample.doc", loadOptions)) {

    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
    viewer.view(viewOptions);
}