thats not the issue here... its about getting the values of proxyHost and
proxyPort when the client is running the desktop application.
I do get the host and port fromthe browser by ProxySelector class.. as i
mentioned above. but the problem is that it just doesnt connect to the
server. connection reset by peer......
I found out that the problem lies in only one line ..
System.setProperty("java.net.useSystemProxies","true");
if i dont do this, the server will respond. or if i immediately write
System.setProperty("java.net.useSystemProxies","false"); after that line
only nothng in between then only it works and server responds..
THis is really creepy.. and i dont know the solution of this problem. but i
need to set this property to true if i want to get the proxy settings of the
browser... :(:(:(
too bad... can anyone pls help???
On 9/12/07, Tobias Meier <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I set the proxy in the HTTPClient in the following way:
>
> SimpleHttpConnectionManager connectionManager = new
> SimpleHttpConnectionManager();
> HttpClient client = new HttpClient(this.connectionManager);
>
> HostConfiguration config =
> this.client.getHostConfiguration();
> //use Proxy
> this.config.setProxy(proxyHost, proxyPort);
>
> //Proxy Authentication
> Credentials defaultcreds = new
> UsernamePasswordCredentials(proxyUser, proxyPassword);
> AuthScope proxyScope = new AuthScope( proxyHost, proxyPort
> );
> this.client.getState().setProxyCredentials(proxyScope,
> defaultcreds);
>
> regards,
> ToM
>
>
> Am Mi 12.09.2007 13:55 schrieb nitya vyas <[EMAIL PROTECTED]>:
>
> > I get the proxy settings with following code..... userful one...
> >
> > System.setProperty("java.net.useSystemProxies","true");
> > List l = ProxySelector.getDefault().select(new URI("
> > https://www.yahoo.com"));
> > for (Iterator iter = l.iterator(); iter.hasNext(); ){
> > Proxy proxy1 = (Proxy) iter.next();
> > System.out.println("proxy type : " + proxy1.type());
> > InetSocketAddress addr = (InetSocketAddress)
> > proxy1.address();
> > if(addr == null){
> > System.out.println("No Proxy");
> > }else{
> > String proxyHost = addr.getHostName();
> > int proxyPort = addr.getPort();
> > System.out.println("proxy hostname : " +
> > addr.getHostName());
> > System.out.println("proxy port : " + addr.getPort
> > ());
> > }
> > }
> >
> > When i run this code i get the proxy settings of the IE.. eventhough
> > my
> > default browser is Firefox i got the settings from IE. i checked the
> > same by
> > removing from IE and didnt get anything in that case..
> >
> > Now when i use the same httpClient object with setting proxy... and
> > try to
> > execute the method... httpClient.executeMethod(xyz) it just stops
> > there..
> > and then after a long wait it gives java.net.SocketException:
> > Connection
> > reset ......
> >
> > i dont know wat is wrong.. can anyone throw some light on this?????
> >
> > thanks
> >
> > On 9/6/07, Puneet Lakhina <[EMAIL PROTECTED]> wrote:
> > >
> > > On 8/29/07, nitya vyas <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi there,
> > > > I am using a single HTTPClient object (static) for the desktop
> > > application
> > > > with different method objects (get,post,multipartpost) for each
> > > > call..I
> > > > have also implemented StrictSSLSocketFactory implementation (SSL)
> > > > for
> > > that
> > > > httpClient object. Now i m suppose to get the proxy information
> > > > from the
> > > > default browser and set the proxy for all requests. I believe it
> > > > must be
> > > > done for the same static httpClient object for my app but dont
> > > > know
> > > how..
> > >
> > >
> > > Two things
> > > 1. How to get the default proxy settings from the system. IDid some
> > > googling
> > > on this, found no way to easily get the windows default internet
> > > settings
> > > (similar to what firefox can do on windows when you install and run
> > > it).
> > >
> > > 2. How to set a proxy - I have done this for absolute basic
> > > httpclient,
> > > dont
> > > know if anything different needs to be done for SSL connections. For
> > > this
> > > you can use the HostConfiguration parameter of the executeMethod
> > > method.
> > > Something like this
> > > HttpClient httpClient = new HttpClient();
> > > GetMethod getMethod = new GetMethod("http://www.apache.org/");
> > > HostConfiguration hostConfig = new HostConfiguration();
> > > //set proxy host and port
> > > hostConfig.setProxy("my.proxy.address",80);
> > >
> > > client.executeMethod(getMethod,hostConfig);
> > > //Dont forget
> > > method.releaseConnection();
> > >
> > >
> > > can anyone please guide me how this can be achieved? I think
> > > setProxy()
> > > can
> > > > be done on HttpConnection object and not HTTPClient. So how do i
> > > > set the
> > > > proxy for my httpClient ???
> > > >
> > > > thanks.
> > > > Nitya
> > > >
> > >
> > > Hope it helps.
> > >
> > > --
> > > Puneet
> > >
>
>
> VieleGrüße,
> TobiasMeier
> __________________________________________________
> MSc,Dipl.-Inf.TobiasMeier
> Softwareentwickler
> nepatecGmbH&Co.KG
> Hindenburgstr.37.30175Hannover
> Fon+49(0)511935946.51,Fax+49(0)511935946.57
> Mailto:[EMAIL PROTECTED]
> http://www.nepatec.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>