Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description A clear and concise description of what the bug is about.

When I use the OllamaChatModel, a timeout error occurs

at NioSocketImpl

private int timedRead(FileDescriptor fd, byte[] b, int off, int len, long nanos)
    throws IOException
{
    long startNanos = System.nanoTime();
    int n = tryRead(fd, b, off, len);
    while (n == IOStatus.UNAVAILABLE && isOpen()) {
        long remainingNanos = nanos - (System.nanoTime() - startNanos);
        if (remainingNanos <= 0) {
            throw new SocketTimeoutException("Read timed out");
        }
        park(fd, Net.POLLIN, remainingNanos);
        n = tryRead(fd, b, off, len);
    }
    return n;
}

How to configure timeout?

Environment Please provide as many details as possible: Spring AI version, Java version, which vector store you use if any, etc 1.0.0-SNAPSHOT

Steps to reproduce Steps to reproduce the issue.

Expected behavior A clear and concise description of what you expected to happen.

Minimal Complete Reproducible example Please provide a failing test or a minimal complete verifiable example that reproduces the issue. Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Comment From: zjarlin

Spring-ai Caused by: java.net.SocketTimeoutException: Read timed out This problem is fixed when I define RestClient myself, but I don't know if I will introduce other bugs

Comment From: ThomasVitale

For the time being, you can customise the timeout by defining a RestClientCustomizer as shown in this example: https://github.com/ThomasVitale/llm-apps-java-spring-ai/blob/main/10-observability/observability-models-ollama/src/main/java/com/thomasvitale/ai/spring/HttpClientConfig.java#L16

In the future, it should be possible to have a more specific way to configure timeouts for the Spring AI Clients (see: https://github.com/spring-projects/spring-ai/issues/512).

Comment From: zjarlin

thanks

Comment From: account123456789

For the time being, you can customise the timeout by defining a RestClientCustomizer as shown in this example: https://github.com/ThomasVitale/llm-apps-java-spring-ai/blob/main/10-observability/observability-models-ollama/src/main/java/com/thomasvitale/ai/spring/HttpClientConfig.java#L16

In the future, it should be possible to have a more specific way to configure timeouts for the Spring AI Clients (see: #512).

I am facing this issue

com.google.api.gax.rpc.UnknownException: java.net.SocketTimeoutException: Read timed out

How did you manage to solve it , it is pointing to rpc instead of using the property

spring.ai.vertex.ai.gemini.transport=rest

Please help ??