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

No Timeout Configuration for readLocation/read Method #2156

Open
sohitkumar opened this issue Jan 23, 2025 · 0 comments
Open

No Timeout Configuration for readLocation/read Method #2156

sohitkumar opened this issue Jan 23, 2025 · 0 comments

Comments

@sohitkumar
Copy link

I am facing challenges with the readLocation method in swagger-parser. When attempting to load an OpenAPI specification from a remote URL that is not reachable, the method takes around 2 minutes before it throws an exception and reaches the catch block.

This behavior seems to stem from the lack of explicit connection and read timeout configurations within the swagger-parser library.

Use Case
In scenarios where the remote URL is invalid, unreachable, or timing out, I would expect the parser to throw an error immediately or within a reasonable timeout period. However, currently, the method appears to rely on the underlying HTTP client's default timeout settings (which can be quite high, e.g., 120 seconds), causing unnecessary delays in the application flow.

Expected Behavior
Provide a way to configure:

Connection Timeout: Maximum time to establish a connection to the remote server.
Read Timeout: Maximum time to wait for a response after the connection is established.

For example, I would like to set these timeouts explicitly when using the readLocation method:

SwaggerParseResult parseResult = parser.readLocation( url, null, null, connectionTimeout = 3000, // Connection timeout (in milliseconds) readTimeout = 5000 // Read timeout (in milliseconds) );

Is there best workarounds for this ?

@sohitkumar sohitkumar changed the title No Timeout Configuration for readLocation Method No Timeout Configuration for readLocation/read Method Jan 23, 2025
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

1 participant