Solved

IE4 behind a proxy server

Posted on 1998-05-22
10
363 Views
Last Modified: 2010-08-05
I have an applet that uses http to communicate to a process running on its host.  This applet works fine when not behind a  firewall, and I know how to configure Navigator 4 so that it does not prevent the applet from communicating when run behind a firewall.

How can I convince IE 4 to allow the http connection?

The proxy forces a DNS lookup which violates an applet security requirment.  Netscape has a technique for avoiding this, does Microsoft?
0
Comment
Question by:gerry99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1221370
How is your APPLET accessing the remote host?  Is it using "raw" java.net.Socket calls or java.net.URLConnection?  If using Socket, then you must determine if a proxy is present and talk to the proxy yourself.  If using URLConnection, the library will detect your proxy setting by itself and talk through the proxy as needed.
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221371
I'm currently using Socket, because I want to use the CGI Post format.

Some code:

      // get name of html data page
      String sQuery = "POST " + m_source + " HTTP/1.0\r\n"
            + "Content-type: application/x-www-form-urlencoded\r\n"
            + "Content-length: " + m_content.length() + "\r\n\r\n"
            + m_content;
              try       
      {
            // open a socket - m_host set to documentBase, port = 80
            sock = new Socket( m_host, m_port );
            // get data streams
            outStrm = new DataOutputStream( sock.getOutputStream() );
            inStrm = new DataInputStream( sock.getInputStream() );
            // send the request
            outStrm.writeBytes( sQuery );
            // read the page
            while( (line = inStrm.readLine()) != null )
                     // do something with response


0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1221372
If you're using Socket, you have to use some type of setting to tell your applet to talk to/through the HTTP proxy instead of directly to the remote system.  Basically everything is the same except the following:

1) Instead of opening a Socket to the remote server, you open a Socket to the proxy server and it's port.

2) The HTTP is the same except that you put the full URL (i.e. http://www.remote.com/page.html) where you would normally put just /page.html.

The proxy will do what you ask for you and you will get a response back from the proxy as though you were talking directly to the remote server.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:gerry99
ID: 1221373
Do I need to determine the url of the proxy? and its port?
How would I do that?

In your point 2)
My socket is opened using the full URL of the applet's originating host.  I'm not using
partial URLs here.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221374
You need to ask your firewall/proxy administrator what the address and port of the proxy are.  If your web browser works, it seems to me that you must already know it.

Your m_source is normally just the page or script you want at the host.  Something like /page.html.  When talking to a proxy, you give the proxy the full URL of what you want.  So in your example, m_source would be something like:

http://www.remote.com/page.html:80

0
 
LVL 1

Author Comment

by:gerry99
ID: 1221375
jhance,

I'm going to take some time, to see if I can implement my
http based query using a URLConnection.  I'll get back to you.

The applet in question is available on the public internet, and
can be accessed by people behind firewalls and proxies that I've
never heard of, and that I can't encode into my applet.  I suppose I could prompt for proxy information, but that is too technical for the audience I'm targetting.

The root of my frustration is that connecting back the the host, is well within the sandbox requirements, and yet it can fail based on external networking considerations, and browser type.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221376
Again, that's the purpose of the URLConnection.  It uses the browser's setup to connect either directly or via a proxy if that's what is configured.  If the browser isn't setup right, then it's a mute point as the user won't ever get to your applet to begin with.  The Socket class is a lower level class that gives you (the programmer) more control over the connection.
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221377
I've created some code that uses the URLConnection.  I'm still waiting to find out if this fixes the proxy problem.

During testing I've noticed that the connection.getOutputStream" throws an exception with Netscape 4.05 (JDK 1.5 preview version).

This is my code:

url = new URL( "http", m_host, m_port, m_source );
connection = url.openConnection();
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-length", Integer.toString(m_content.length()) );
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches( false );
connection.connect();

outStrm = new DataOutputStream( connection.getOutputStream() );
outStrm.writeBytes( m_content );
outStrm.flush();
outStrm.close();

inStrm = new DataInputStream( connection.getInputStream() );
// read the response                  String line;
while( (line = inStrm.readLine()) != null )
{
     // do something
}

This is the exception:
# Applet exception: Already connected
java.lang.IllegalAccessError: Already connected
  at java.lang.Throwable.<init>(Compiled Code)
  at java.lang.Error.<init>(Compiled Code)
  at java.lang.LinkageError.<init>(Compiled Code)
  at java.lang.IncompatibleClassChangeError.<init>(Compiled Code)
  at java.lang.IllegalAccessError.<init>(Compiled Code)
  at netscape.net.URLConnection.getOutputStream(Compiled Code)
* at sw.common.data.Preferences.MakeQuery(Compiled Code)
  at sw.common.data.Preferences.run(Compiled Code)
  at java.lang.Thread.run(Compiled Code)
java.io.IOException: CreateProcess: vcafe -netscape error=2
  at java.lang.Win32Process.<init>(Compiled Code)
  at java.lang.Runtime.exec(Compiled Code)
* at java.lang.Runtime.exec(Compiled Code)
  at netscape.debug.Debugger.launchDebugger(Compiled Code)
  at netscape.debug.Debugger.uncaughtException(Compiled Code)
  at netscape.applet.AppletThreadGroup.uncaughtException(Compiled Code)

IllegalAccessError is normally thrown if the runtime libary has
changed method or variables in an incompatible way.

From my documentation:
"Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.

Normally, this error is caught by the compiler; this error can only occur at run-time if the definition of a class has incompatibably changed. "

The code above works fine with IE 4.

Any suggestions?
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221378
Jhance,

I've had a client test my new code using URLConnection instead of
Socket, with IE4, behind a firewall/proxy and apparently it still fails.  I'm not sure of the exact nature of the failure.

I'm prepared to accept your answer if you can clarify the following.  A URLConnection will use whatever proxy setup the user has encoded in their browser.  Is this correct?  If so then by definition any applet loaded from the internet that uses URLConnection should be able to communicate back to its host using a fully specified URL (http://myhost.com/myCGI) and the URLConnection.

BTW, with the last exception, I discovered the Netscape and MS both work fine if you remove the "connection.connect();" line.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221379
I don't find the connect() method as one listed in the URLConnection class.  I'm looking at the JDK 1.02 docs but I don't see it.

A URLConnection when run in a applet within IE or Navigator will use the proxy settings of the host browser environment. This is the exception to the Java applet security rule where the only network connections an applet can make are back to the server which served up the applet.


0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question