0

I want to handle data from a website. I need to handle sessions, so I need to send cookies. But if my program waits longer than 60 seconds to request a new site, the DNS resolver will bring me a new ip so my program will connect to another server which doesn't have my session.

Is it possibile to connect to the same server (IP) via HTTPConnection?

1
  • personally i'd use apache http components (hc.apache.org) for anything non-trivial Commented Dec 28, 2012 at 16:09

1 Answer 1

1

you could resolve the host name to an ip at the start, rewrite the url to use the IP instead of the host name and then you wont have to worry about DNS at all

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

4 Comments

This may not work if this is a shared hosting where the hostname is important.
@rekire that's what the Host-header is for. You always connect to an IP address. I do not know if the HttpConnection offers this option (say in a constructor parameter named virtualHost or by setting a property), or if it automatically uses the host portion of the URL you feed it.
...which is why i'd use apache httpComponents
this doesn't work, i wrote a workaround with java.security.Security.setProperty("networkaddress.cache.ttl", "300");

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.