Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: java.net.SocketTimeoutException: Read timed out #1250

Closed
zjarlin opened this issue Aug 20, 2024 · 3 comments
Closed

Caused by: java.net.SocketTimeoutException: Read timed out #1250

zjarlin opened this issue Aug 20, 2024 · 3 comments

Comments

@zjarlin
Copy link

zjarlin commented Aug 20, 2024

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
<spring-ai.version>1.0.0-SNAPSHOT</spring-ai.version>

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.

@zjarlin
Copy link
Author

zjarlin commented Aug 20, 2024

image This problem is fixed when I define RestClient myself, but I don't know if I will introduce other bugs

@ThomasVitale
Copy link
Contributor

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).

@zjarlin
Copy link
Author

zjarlin commented Aug 20, 2024

thanks

@zjarlin zjarlin closed this as completed Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants