Proxy-problem

S

Sven Junge

Hello,

I'm behind a Firewall and trying to connect with the following code to an
inet-address:

URL url = new URL(urlStr);
InputStream uin = url.openStream();
BufferedReader in = new BufferedReader( new InputStreamReader(uin));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line==null)
more = false;
else
System.out.println( line );
}

My problem is that I can read out every HTML-code I get from websites within
the LAN, but by trying to connect to public sites in the net I only get this
exception:
"java.net.SocketException: Unexpected end of file from server"

Thanks for your help!

Sven Junge
 
Y

Yu SONG

Sven said:
Hello,

I'm behind a Firewall and trying to connect with the following code to an
inet-address:

URL url = new URL(urlStr);
InputStream uin = url.openStream();
BufferedReader in = new BufferedReader( new InputStreamReader(uin));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line==null)
more = false;
else
System.out.println( line );
}

My problem is that I can read out every HTML-code I get from websites within
the LAN, but by trying to connect to public sites in the net I only get this
exception:
"java.net.SocketException: Unexpected end of file from server"

Thanks for your help!

Sven Junge

If you experience problems with accessing sites on the internet while
everything is fine within the LAN, I would suggest you to have a look at
the firewall settings.

btw, you'd better use InputStream rather than Reader

--
Song

/* E-mail.c */
#define User "Yu.Song"
#define Warwick "warwick.ac.uk"
int main() {
printf("Yu Song's E-mail: %s@%s", User, Warwick);
return 0;}

Further Info. : http://www.dcs.warwick.ac.uk/~esubbn/
_______________________________________________________
 
S

Sven Junge

No, that wasn't the problem.
I got a hint to add following code:

System.setProperty( "proxySet", "true" );
System.setProperty( "http.proxyHost", "MyProxyAddress" );
System.setProperty( "http.proxyPort", "MyProxyPort" );

Now it works fine.

thx

Sven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top