Is it possible to make a Direct connection to the Internet without using a Proxy.
Consider a case that my Organization has a Proxy and I use the DIRECT option given in the Java Proxy class.
SocketAddress addr = new
InetSocketAddress("webcache.mydomain.com", 8080);
Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);
If you go by the documentation it states DIRECT which represents a direct connection, or absence of proxy.
Which is exactly the way it behaves. When I use this option, I dont have to give any Proxy details and I can access the content from the Internet.
I have three questions
Thanks in advance.
Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);
Is not the proper way to create a direct (no proxy) proxy directive. You should do
Proxy proxy = Proxy.NO_PROXY
The internal implementation of the Socket class and the HttpURLConnection checks if proxy == Proxy.NO_PROXY
(note: "==", not "equals()"!).
It does NOT check if proxy.getType() == Proxy.Type.DIRECT
.
2) You might have set the proxy in any system properties. If you are using any IDE, check the proxy setting of the IDE.
Not all Network traffic goes through a Proxy, if your Organization has a Proxy. You can still go ahead and establish a Direct connection to the Internet. Mostly the Organizations will block Direct connections and force you to use Proxies. Some times they might allow you to have a Restricted Direct connection, which allows certain URL's and denies other ones.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.