You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dale Harris <it...@martinjonkersmotors.com.au> on 2009/05/27 06:34:36 UTC

TelnetClient in common.net v2.0

Hi,

 

I'm having trouble establishing a TelnetClient connection.   I believe my
issue is something to do with java.net.Socket class trying to use a proxy
server as I can open a Socket with no proxy.  How can I turn off the proxy
before trying to connect with the TelnetClient class?

 

Regards,

 

Dale Harris

IT Support


Re: TelnetClient in common.net v2.0

Posted by James Carman <ja...@carmanconsulting.com>.
On Wed, May 27, 2009 at 6:50 PM, Dale Harris
<it...@martinjonkersmotors.com.au> wrote:
> Thanks for the idea, but doesn't appear to work.  I've added the following
> method to my app to disable the socks proxy host to no joy.
>
>  private void disableSocksProxy() {
>    Properties sysprops = System.getProperties();
>    sysprops.remove("socksProxyHost");
>    sysprops.remove("socksProxyPort");
>    sysprops.remove("java.net.socks.username");
>    sysprops.remove("java.net.socks.password");
>  }
>
> The only way around my issue that I've found so far is to create a
> SocketFactory for the TelnetClient to use.

You might try this:

http://www.thoughtsabout.net/blog/archives/000055.html

Basically, you can tell Java which hosts to bypass the socks proxy
for.  Are you absolutely sure that your code is using a socks proxy?
Can you print out the system properties before you change them (and
before you use the telnet client; perhaps in the first line of a main
method)?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: TelnetClient in common.net v2.0

Posted by sebb <se...@gmail.com>.
On 28/05/2009, Dale Harris <it...@martinjonkersmotors.com.au> wrote:
> Hi Sebb,
>
>  I would have thought in an object orientated language like Java, I would
>  have thought that obtaining a reference to a child object and updating it,
>  it would then automatically be reflected through the parent object.

Sorry, you're right that the properties will be updated.

[Not sure how that relates to object orientation; getProperties()
could equally return a copy of the properties (which is what I thought
it did, but I just checked).]

>  I have checked System.getProperty() for the following items after I removed
>  them, and they then return null.
>

But what does System.getProperty() show before removal?

I.e. does the change make any difference?

Also, you need to check that the change occurs before the relevant
system properties are first used, as they are likely to be cached.

>  Regards,
>
>  Dale Harris
>  IT Support
>
>
>  -----Original Message-----
>
> From: sebb [mailto:sebbaz@gmail.com]
>  Sent: Thursday, 28 May 2009 9:25
>  To: Commons Users List
>  Subject: Re: TelnetClient in common.net v2.0
>
>  On 27/05/2009, Dale Harris <it...@martinjonkersmotors.com.au> wrote:
>  > Thanks for the idea, but doesn't appear to work.  I've added the following
>  >  method to my app to disable the socks proxy host to no joy.
>  >
>  >   private void disableSocksProxy() {
>  >     Properties sysprops = System.getProperties();
>  >     sysprops.remove("socksProxyHost");
>  >     sysprops.remove("socksProxyPort");
>  >     sysprops.remove("java.net.socks.username");
>  >     sysprops.remove("java.net.socks.password");
>  >   }
>
>  That only deletes the properties from "sysprops"; it does not delete
>  the system properties themselves.
>
>  I suggest you display the values of the properties to see if they are
>  actually set.
>
>  >  The only way around my issue that I've found so far is to create a
>  >  SocketFactory for the TelnetClient to use.
>  >
>  >
>  >  Regards,
>  >
>  >  Dale Harris
>  >  IT Support
>  >
>  >
>  >  -----Original Message-----
>  >
>  > From: James Carman [mailto:james@carmanconsulting.com]
>  >  Sent: Wednesday, 27 May 2009 21:08
>  >  To: Commons Users List
>  >  Subject: Re: TelnetClient in common.net v2.0
>  >
>  >  On Wed, May 27, 2009 at 6:58 AM, James Carman
>  >  <ja...@carmanconsulting.com> wrote:
>  >  > There are system properties you can set to "turn on" proxies for the
>  >  > Java networking classes.  That's the default way that Socket would
>  >  > become proxy-aware.
>  >  >
>  >
>  >  FYI:
>  >
>  >  http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  >  For additional commands, e-mail: user-help@commons.apache.org
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  >  For additional commands, e-mail: user-help@commons.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: TelnetClient in common.net v2.0

Posted by Dale Harris <it...@martinjonkersmotors.com.au>.
Hi Sebb,

I would have thought in an object orientated language like Java, I would
have thought that obtaining a reference to a child object and updating it,
it would then automatically be reflected through the parent object.

I have checked System.getProperty() for the following items after I removed
them, and they then return null.

Regards,

Dale Harris
IT Support


-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Thursday, 28 May 2009 9:25
To: Commons Users List
Subject: Re: TelnetClient in common.net v2.0

On 27/05/2009, Dale Harris <it...@martinjonkersmotors.com.au> wrote:
> Thanks for the idea, but doesn't appear to work.  I've added the following
>  method to my app to disable the socks proxy host to no joy.
>
>   private void disableSocksProxy() {
>     Properties sysprops = System.getProperties();
>     sysprops.remove("socksProxyHost");
>     sysprops.remove("socksProxyPort");
>     sysprops.remove("java.net.socks.username");
>     sysprops.remove("java.net.socks.password");
>   }

That only deletes the properties from "sysprops"; it does not delete
the system properties themselves.

I suggest you display the values of the properties to see if they are
actually set.

>  The only way around my issue that I've found so far is to create a
>  SocketFactory for the TelnetClient to use.
>
>
>  Regards,
>
>  Dale Harris
>  IT Support
>
>
>  -----Original Message-----
>
> From: James Carman [mailto:james@carmanconsulting.com]
>  Sent: Wednesday, 27 May 2009 21:08
>  To: Commons Users List
>  Subject: Re: TelnetClient in common.net v2.0
>
>  On Wed, May 27, 2009 at 6:58 AM, James Carman
>  <ja...@carmanconsulting.com> wrote:
>  > There are system properties you can set to "turn on" proxies for the
>  > Java networking classes.  That's the default way that Socket would
>  > become proxy-aware.
>  >
>
>  FYI:
>
>  http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: TelnetClient in common.net v2.0

Posted by sebb <se...@gmail.com>.
On 27/05/2009, Dale Harris <it...@martinjonkersmotors.com.au> wrote:
> Thanks for the idea, but doesn't appear to work.  I've added the following
>  method to my app to disable the socks proxy host to no joy.
>
>   private void disableSocksProxy() {
>     Properties sysprops = System.getProperties();
>     sysprops.remove("socksProxyHost");
>     sysprops.remove("socksProxyPort");
>     sysprops.remove("java.net.socks.username");
>     sysprops.remove("java.net.socks.password");
>   }

That only deletes the properties from "sysprops"; it does not delete
the system properties themselves.

I suggest you display the values of the properties to see if they are
actually set.

>  The only way around my issue that I've found so far is to create a
>  SocketFactory for the TelnetClient to use.
>
>
>  Regards,
>
>  Dale Harris
>  IT Support
>
>
>  -----Original Message-----
>
> From: James Carman [mailto:james@carmanconsulting.com]
>  Sent: Wednesday, 27 May 2009 21:08
>  To: Commons Users List
>  Subject: Re: TelnetClient in common.net v2.0
>
>  On Wed, May 27, 2009 at 6:58 AM, James Carman
>  <ja...@carmanconsulting.com> wrote:
>  > There are system properties you can set to "turn on" proxies for the
>  > Java networking classes.  That's the default way that Socket would
>  > become proxy-aware.
>  >
>
>  FYI:
>
>  http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: TelnetClient in common.net v2.0

Posted by Dale Harris <it...@martinjonkersmotors.com.au>.
Thanks for the idea, but doesn't appear to work.  I've added the following
method to my app to disable the socks proxy host to no joy.

  private void disableSocksProxy() {
    Properties sysprops = System.getProperties();
    sysprops.remove("socksProxyHost");
    sysprops.remove("socksProxyPort");
    sysprops.remove("java.net.socks.username");
    sysprops.remove("java.net.socks.password");
  }

The only way around my issue that I've found so far is to create a
SocketFactory for the TelnetClient to use.

Regards,

Dale Harris
IT Support


-----Original Message-----
From: James Carman [mailto:james@carmanconsulting.com] 
Sent: Wednesday, 27 May 2009 21:08
To: Commons Users List
Subject: Re: TelnetClient in common.net v2.0

On Wed, May 27, 2009 at 6:58 AM, James Carman
<ja...@carmanconsulting.com> wrote:
> There are system properties you can set to "turn on" proxies for the
> Java networking classes.  That's the default way that Socket would
> become proxy-aware.
>

FYI:

http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: TelnetClient in common.net v2.0

Posted by James Carman <ja...@carmanconsulting.com>.
On Wed, May 27, 2009 at 6:58 AM, James Carman
<ja...@carmanconsulting.com> wrote:
> There are system properties you can set to "turn on" proxies for the
> Java networking classes.  That's the default way that Socket would
> become proxy-aware.
>

FYI:

http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: TelnetClient in common.net v2.0

Posted by James Carman <ja...@carmanconsulting.com>.
On Wed, May 27, 2009 at 2:48 AM, Dale Harris
<it...@martinjonkersmotors.com.au> wrote:
> Hi,
>
> I have solved my issue.  I had to set the SocketFactory and create a socket
> with the proxy turned off.  It would be nice to add hints like that to the
> documentation.  Maybe it should default to no proxy too?  Where does the
> Socket class obtain the proxy settings anyway?

There are system properties you can set to "turn on" proxies for the
Java networking classes.  That's the default way that Socket would
become proxy-aware.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: TelnetClient in common.net v2.0

Posted by Dale Harris <it...@martinjonkersmotors.com.au>.
Hi,

I have solved my issue.  I had to set the SocketFactory and create a socket
with the proxy turned off.  It would be nice to add hints like that to the
documentation.  Maybe it should default to no proxy too?  Where does the
Socket class obtain the proxy settings anyway?

Regards,

Dale Harris
IT Support


-----Original Message-----
From: Dale Harris [mailto:itsupport@martinjonkersmotors.com.au] 
Sent: Wednesday, 27 May 2009 14:35
To: user@commons.apache.org
Subject: TelnetClient in common.net v2.0

Hi,

 

I'm having trouble establishing a TelnetClient connection.   I believe my
issue is something to do with java.net.Socket class trying to use a proxy
server as I can open a Socket with no proxy.  How can I turn off the proxy
before trying to connect with the TelnetClient class?

 

Regards,

 

Dale Harris

IT Support


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org