We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In the following example the Connection timeout is 7sec and the url latency is 5sec but i'm getting java.net.SocketTimeoutException: Read timed out
` @RunWith(SpringRunner.class) public class FetcherConcurrentClientApplicationTests {
@test public void simpleTest() { Document doc = null; long startTime = System.nanoTime(); try { doc = Jsoup.connect("http://httpstat.us/200?sleep=5000").timeout(7000).get(); } catch (IOException e) { e.printStackTrace(); } long processingTime = System.nanoTime() - startTime; System.out.println("Processing time: " + TimeUnit.NANOSECONDS.toMillis(processingTime)); assertNotNull(doc); } } `
It's because that when JSoup create a connection it configure the Connection readTimeout to half of the request timeout.
` private static HttpURLConnection createConnection(Connection.Request req) throws IOException { final HttpURLConnection conn = (HttpURLConnection) ( req.proxy() == null ? req.url().openConnection() : req.url().openConnection(req.proxy()) );
conn.setRequestMethod(req.method().name()); conn.setInstanceFollowRedirects(false); // don't rely on native redirection support conn.setConnectTimeout(req.timeout()); conn.setReadTimeout(req.timeout() / 2);
`
The text was updated successfully, but these errors were encountered:
Create a setter method to sets Connection read timeout jhy#1228
4894c4e
514c57f
No branches or pull requests
In the following example the Connection timeout is 7sec and the url latency is 5sec but i'm getting java.net.SocketTimeoutException: Read timed out
`
@RunWith(SpringRunner.class)
public class FetcherConcurrentClientApplicationTests {
@test
public void simpleTest() {
Document doc = null;
long startTime = System.nanoTime();
try {
doc = Jsoup.connect("http://httpstat.us/200?sleep=5000").timeout(7000).get();
} catch (IOException e) {
e.printStackTrace();
}
long processingTime = System.nanoTime() - startTime;
System.out.println("Processing time: " + TimeUnit.NANOSECONDS.toMillis(processingTime));
assertNotNull(doc);
}
}
`
It's because that when JSoup create a connection it configure the Connection readTimeout to half of the request timeout.
`
private static HttpURLConnection createConnection(Connection.Request req) throws IOException {
final HttpURLConnection conn = (HttpURLConnection) (
req.proxy() == null ?
req.url().openConnection() :
req.url().openConnection(req.proxy())
);
`
The text was updated successfully, but these errors were encountered: