# java.net.SocketTimeoutException: Read timed out

- **ID:** `java/socket-timeout-exception-read-timed-out`
- **Domain:** java
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

A socket read operation did not receive data within the configured timeout period, typically due to network latency, server overload, or firewall blocking.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Java 8 | active | — | — |
| Java 11 | active | — | — |
| Java 17 | active | — | — |
| Java 21 | active | — | — |

## Workarounds

1. **Increase the read timeout to a reasonable value (e.g., 30 seconds) using socket.setSoTimeout(30000), and implement a retry mechanism with exponential backoff.** (80% success)
   ```
   Increase the read timeout to a reasonable value (e.g., 30 seconds) using socket.setSoTimeout(30000), and implement a retry mechanism with exponential backoff.
   ```
2. **Check network connectivity with 'ping server-host' and verify server logs for latency or errors; use a connection pool with timeout settings.** (70% success)
   ```
   Check network connectivity with 'ping server-host' and verify server logs for latency or errors; use a connection pool with timeout settings.
   ```

## Dead Ends

- **** — This only delays the failure; if the server is unresponsive, the connection will eventually time out, and it may block threads unnecessarily. (60% fail)
- **** — This can cause infinite loops or resource exhaustion if the server never responds, and may overwhelm the network. (75% fail)
