7

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
  • tried with removing the urlc.setConnectTimeout(1000 * 20); and still got the exception.
  • checked with http instead of https URL url = new URL("http://results.bput.ac.in/"); but got no result.
  • cheked with URL url = new URL("https://www.facebook.com/"); and got success response.
  • Checked with changing the timeout period but same exception .

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.

4
  • is that link working ? Commented Apr 4, 2016 at 4:40
  • i have edited my question. @PankajNimgade the link works. Commented Apr 4, 2016 at 4:43
  • 1
    i tried that link in browser, but it times out, are you sure Commented Apr 4, 2016 at 4:45
  • i tried it now @PankajNimgade and this took like 1 sec to load . Commented Apr 4, 2016 at 4:47

2 Answers 2

2

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 both IPv6 and IPv4 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.

Sign up to request clarification or add additional context in comments.

10 Comments

what would i do then ? any solution ?
Be sure that you can open that URL and establish proper connection. your server is not responding but https://www.facebook.com will do, so that it's working fine. This means you have nothing to do with this error in client side untill you fix the connection timeout problem.
i have also tried not giving any timeout period and thats giving error too .
No, that won't work, don't remove that. Just be sure you can open that URL from your device's browser in short duration of time.
If you can smoothly open that from your browser then your code should work fine. But i think it's still lagging. It's not being opened by us.
|
0

I tried both https://results.bput.ac.in/ and http://results.bput.ac.in/ and both timed out. Probably you haven't opened ports 80 and/or 443 in the server firewall.

1 Comment

how do i do that ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.