I have used following code to connect -
URL url = new URL("https://results.bput.ac.in/");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
urlc.setConnectTimeout(1000 * 20);
urlc.connect();
It returned a SocketTimeoutException .
Exception
The exact exception i am getting is
java.net.SocketTimeoutException: failed to connect to results.bput.ac.in/14.139.212.166 (port 443) after 90000ms
and sometimes this -
java.net.SocketTimeoutException: failed to connect to results.bput.ac.in/14.139.212.166 (port 80) after 90000ms
urlc.setConnectTimeout(1000 * 20);
and still got the exception.URL url = new URL("http://results.bput.ac.in/");
but got no result.URL url = new URL("https://www.facebook.com/");
and got success response.The problem is with this specific url - http://results.bput.ac.in/
.
Information
This link i have given http://results.bput.ac.in/
is perfectly working on any web browser without any lagging .
I got information that some guys cant open this site , its lagging but i can open it without any lag .
My Research
I have already tried this SO question , this SO question , this github solution and java code geeks solution but got no result.
Update
I have tested this with my wifi and mobile data by thinking that my router might have some problem with the port. but i got same exception with mobile data too.
Do anyone have any solution to this.
Using try/catch/finally. If you are a developer, so you can surround the socket connection part of your code in a try/catch/finally and handle the error in the catch. You might try connecting a second time, or try connecting to another possible socket, or simply exit the program cleanly.
A possible solution for this problem within the Tomcat web application is to modify the CONTEXT. XML file, and modify the CONNECTOR definition that governs the workstation browser connectivity to the Tomcat server. Specifically, modify the connectionTimeout value. Increase this value to suppress the error condition.
If the timeout elapses before the method returns, it will throw a SocketTimeoutException. Sometimes, firewalls block certain ports due to security reasons. As a result, a “connection timed out” error can occur when a client is trying to establish a connection to a server.
SocketTimeoutException: Read timed out. This error is typically caused by a maximum concurrent connections limit on the SFTP server itself (either total concurrent connections or concurrent connections from a specific IP).
If the
hostname
resolves to multiple IP addresses, this client will try each in RFC 3484 order. If connecting to each of these addresses fails, multiple timeouts will elapse before the connect attempt throws an exception. Host names that support bothIPv6
andIPv4
always have at least 2 IP addresses.-- Doc
You have already used setConnectTimeout()
and added maximum time as well so no doubt on that. The main reason of SocketTimeoutException is if the timeout elapses before a connection is established.
Then the main and certain reason is Connection with your server could not be established.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With