Problems re-routing with SOCKS Proxy Servers

I am making a TCP client and am trying to use an anonymous proxy server to re-route the connection inbetween.
I have tried many, many servers but when trying:
System.out.println(s.isConnected());
it always returns false and the client ends up directly connecting.
Here is the code that I am trying. once again, using a SOCKS server for TCP.
Socket s = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ipAddress, port)));

After you construct the socket you have to call connect() with the real target.

Similar Messages

  • Application Server slowdown with multiple proxy servers ?

    Our environment has our iAS boxes talking to iWS web servers which are front-ended with iPlanet Proxy servers (Proxy 3.53 I believe). We are seeing significant slowdown if we try and hit our web apps through the proxy as opposed to going directly to the web server (bypassing the proxy servers). One of our "proxy" guys recalls hearing that there is an issue with the app server's handling of sessions if requests from the same user come in to the web server (and by extension the app server) from multiple proxy servers with different ip's. Has any body ever encountered this or does any body know if the app server has an issue handling the same sessions whose requests come from different ip addresses (different proxies)?

    The proxy work with HTTP 1.0 and the webserver with HTTP 1.1.
    This difference could be the cause of your problems.
    "David Fuelling" <[email protected]> escribio en el mensaje
    news:[email protected]..
    Our environment has our iAS boxes talking to iWS web servers which are
    front-ended with iPlanet Proxy servers (Proxy 3.53 I believe). We
    are seeing significant slowdown if we try and hit our web apps through
    the proxy as opposed to going directly to the web server (bypassing
    the proxy servers). One of our "proxy" guys recalls hearing that
    there is an issue with the app server's handling of sessions if
    requests from the same user come in to the web server (and by
    extension the app server) from multiple proxy servers with different
    ip's. Has any body ever encountered this or does any body know if the
    app server has an issue handling the same sessions whose requests come
    from different ip addresses (different proxies)?
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Authenticating to Socks proxy using different accounts in a given JVM

    I have a J2EE application that runs some background jobs. Each of these background jobs need to connect to an external FTP server. However, all connections must go through a central SOCKS proxy server. The SOCKS proxy server is set up to require authentication using user names and passwords. Everything works fine if I've to use this SOCKS proxy with "a set" of credentials across all background jobs. However, if I want Job1 to use "user1" for SOCKS login, and Job2 to use "user2" for SOCKS login, I can't seem to find a way to do this. I need this functionality for accounting purposes. Any help on how this can be accomplished is greatly appreciated.
    Regards,
    Sai Pullabhotla

    I tried implementing the ThreadLocal idea and I think the code is working as expected, but my proxy logs are not matching up with what the code says. Below is the code I've including a test class. See below the code for my additional comments.
    import java.net.Authenticator;
    import java.net.PasswordAuthentication;
    * A customer authenticator for authenticating with SOCKS Proxy servers.
    public class ProxyAuthenticator extends Authenticator {
          * A thread local for storing the credentials to the SOCKS proxy. The Javadoc
          * for ThreadLocal says they are typically used for static fields, but
          * here I've a singleton instance. Hope this is not an issue.
         private ThreadLocal<PasswordAuthentication> credentials = null;
          * Singleton instance.
         private static ProxyAuthenticator instance = null;
          * Creates a new instance of <code>ProxyAuthenticator</code>. Each thread
          * will have its own copy of credentials, which would be <code>null</code>
          * initially. Each thread must call the <code>setCredentials</code> method
          * to set the proxy credentials if needed.
         private ProxyAuthenticator() {
              credentials = new ThreadLocal<PasswordAuthentication>() {
                   @Override
                   protected PasswordAuthentication initialValue() {
                        System.out.println("ThreadLocal initialized for "
                             + Thread.currentThread().getName());
                        return null;
                   @Override
                   public void set(PasswordAuthentication value) {
                        System.out.println(Thread.currentThread().getName() + " SET");
                        super.set(value);
                   @Override
                   public PasswordAuthentication get() {
                        System.out.println(Thread.currentThread().getName() + " GET");
                        return super.get();
          * Returns the singleton instance of this class.
          * @return the singleton instance of this class.
         public static synchronized ProxyAuthenticator getInstance() {
              if (instance == null) {
                   instance = new ProxyAuthenticator();
              return instance;
          * Sets the proxy creditials. This method updates the ThreadLocal variable.
          * @param user
          *            the user name
          * @param password
          *            the password
         public void setCredentials(String user, String password) {
              credentials.set(new PasswordAuthentication(user, password.toCharArray()));
         @Override
         public PasswordAuthentication getPasswordAuthentication() {
              System.out.println("Requesting host: " + this.getRequestingHost());
              System.out.println("Requesting port: " + this.getRequestingPort());
              System.out.println("Requesting protocol: "
                   + this.getRequestingProtocol());
              System.out.println("Requesting prompt: " + this.getRequestingPrompt());
              System.out.println("Requesting scheme: " + this.getRequestingScheme());
              System.out.println("Requesting site: " + this.getRequestingSite());
              System.out.println("Requesting URL: " + this.getRequestingURL());
              System.out.println("Requestor type: " + this.getRequestorType());
              System.out.println(Thread.currentThread().getName()
                   + " Authenitcator returning credentials "
                   + credentials.get().getUserName() + ":"
                   + new String(credentials.get().getPassword()));
              return credentials.get();
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.Authenticator;
    import java.net.InetSocketAddress;
    import java.net.Proxy;
    import java.net.Socket;
    import java.net.Proxy.Type;
    * A test class for testing the {@link ProxyAuthenticator}.
    public class SocksProxyTest implements Runnable {
          * Socks proxy host, used by the FakeFtpClient
         private static final String SOCKS_PROXY_HOST = "192.168.1.240";
          * Target FTP host to connect to
         private String host = null;
          * Proxy user
         private String proxyUser = null;
          * Proxy password
         private String proxyPassword = null;
          * Creates a new instance of <code>SocksProxyTest</code>
          * @param host
          *            the target FTP host
          * @param proxyUser
          *            proxy user
          * @param proxyPassword
          *            proxy password
         public SocksProxyTest(String host, String proxyUser, String proxyPassword) {
              this.host = host;
              this.proxyUser = proxyUser;
              this.proxyPassword = proxyPassword;
         public void run() {
              // Create the FakeFtpClient
              FakeFtpClient test = new FakeFtpClient(host, 21, proxyUser,
                   proxyPassword);
              for (int j = 0; j < 5; j++) {
                   try {
                        test.connect();
                        test.disconnect();
                        // Thread.sleep(10000);
                   catch (Throwable t) {
                        t.printStackTrace();
          * Test run.
          * @param args
          *            command line arguments
          * @throws IOException
          *             propagated
         public static void main(String[] args) throws IOException {
              // Get the singleton instance of the ProxyAuthenticator.
              ProxyAuthenticator authenticator = ProxyAuthenticator.getInstance();
              // Update the default authenticator to our ProxyAuthenticator
              Authenticator.setDefault(authenticator);
              // Array of FTP hosts we want to connect to
              final String[] ftpHosts = { "192.168.1.53", "192.168.1.54",
                        "192.168.1.55" };
              // Proxy login/user names to connect to each of the above hosts
              final String[] users = { "User-001", "User-002", "User-003" };
              // Proxy passwords for each of the above user names (in this case
              // password == username).
              final String[] passwords = users;
              // For each target FTP host
              for (int i = 0; i < 3; i++) {
                   // Create the SocksProxyTest instance with the target host, proxy
                   // user and proxy password
                   SocksProxyTest spt = new SocksProxyTest(ftpHosts, users[i],
                        passwords[i]);
                   // Create a new thread and start it
                   Thread t = new Thread(spt);
                   t.setName("T" + (i + 1));
                   try {
                        t.join();
                   catch (InterruptedException e) {
                        e.printStackTrace();
                   t.start();
         * A fake FTP client. The connect method connects to the given host, reads
         * the first line the server sends. Does nothing else. The disconnect method
         * closes the socket.
         private static class FakeFtpClient {
              * The FTP host
              private String host = null;
              * The FTP port
              private int port = 0;
              * Proxy login/user name
              private String proxyUser = null;
              * Proxy password
              private String proxyPassword = null;
              * Socket to the target host
              private Socket s = null;
              * Creates a new instance of <code>FakeFtpClient</code>
              * @param host
              * the FTP host
              * @param port
              * the FTP port
              * @param proxyUser
              * Proxy user
              * @param proxyPassword
              * Proxy password
              public FakeFtpClient(String host, int port, String proxyUser,
                   String proxyPassword) {
                   this.host = host;
                   this.port = port;
                   this.proxyUser = proxyUser;
                   this.proxyPassword = proxyPassword;
              * Connects to the target FTP host through the specified Socks proxy and
              * proxy authentication. Reads the first line of the welcome message.
              * @throws IOException
              * propagated
              public void connect() throws IOException {
                   System.out.println(Thread.currentThread().getName()
                        + " Connecting to " + host + " ...");
                   // Update the ProxyAuthenticator with the correct credentials for
                   // this thread
                   ProxyAuthenticator.getInstance().setCredentials(proxyUser,
                        proxyPassword);
                   s = new Socket(new Proxy(Type.SOCKS, new InetSocketAddress(
                        SOCKS_PROXY_HOST, 1080)));
                   s.setSoTimeout(10000);
                   s.connect(new InetSocketAddress(host, port), 10000);
                   System.out.println(Thread.currentThread().getName() + " Connected");
                   BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                        s.getOutputStream()));
                   BufferedReader reader = new BufferedReader(new InputStreamReader(
                        s.getInputStream()));
                   System.out.println(reader.readLine());
              * Closes the socket.
              public void disconnect() {
                   System.out.println(Thread.currentThread().getName()
                        + " Disconnecting...");
                   if (s != null) {
                        try {
                             s.close();
                             System.out.println(Thread.currentThread().getName()
                                  + " Disconnected");
                        catch (IOException e) {
                             e.printStackTrace();
    Looking at the test class, it creates 3 threads T1, T2 and T3. T1 is setup to connect to 192.168.1.53 using a proxy user User-001 and T2 is setup to connect to 192.168.1.54 using proxy user User-002 and T3 connects to 192.168.1.55 using proxy user User-003.
    Each thread then loops 5 times to connect to their target servers and disconnect each time. All the debug (System.out) statements indicate that the getPasswordAuthentication is returning the correct credentials for each thread. However, when I look at the logs on the proxy server, the results are different and arbitrary.
    Below is the proxy log:
    [2011-01-24 11:10:11] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
    [2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
    [2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.55:21
    [2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
    [2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
    [2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
    [2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.55:21
    [2011-01-24 11:10:11] 192.168.1.240 User-003 SOCKS5 CONNECT 192.168.1.54:21
    [2011-01-24 11:10:11] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
    [2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
    [2011-01-24 11:10:12] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
    [2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
    [2011-01-24 11:10:12] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
    [2011-01-24 11:10:12] 192.168.1.240 User-001 SOCKS5 CONNECT 192.168.1.54:21
    [2011-01-24 11:10:13] 192.168.1.240 User-002 SOCKS5 CONNECT 192.168.1.53:21
    As you can see from the first line in the log, the proxy says User-001 connected to 192.168.1.54, but the code should always connect to 192.168.1.53 with user User-001.
    Any idea on what might be going on?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Configuring Proxy servers for Mail.app

    Hello, and sorry if this question has been answered b4, but I couldn't find an answer... basically, I have to go thru proxy server at work to connect to the internet on my MBP, which I configured with Network Preferences (I enabled ftp, http, https, socks, and ITMS proxies.. Safari works fine, but can't get Mail to retrieve any mail from either of my mailboxes (.Mac and Gmail POP). the same prob. doesn't happen when i'm home trying to access my Mail from home (where i don't have to go thru proxy servers) using my macbook pro. the question is, how can i "tell" Mail that i'm using a proxy server?? thanks

    No, actually i tried it first with socks proxy disabled, and then with it enabled, but nothing appears to be working.. it sounds a little strange to me that Mail.app doesn't contain specific settings that allow users behind company proxies to still access their mail servers, b/c for whatever reason Mail.app doesn't appear to be using the default system-wide proxy settings specfied in network preferences, which by the way Safari picked up right away and started using. well, any further help on this would be much appreciated, thanks .....

  • IChat Socks Proxy?

    I'm having problems connecting to a Socks proxy using iChat. I know the socks proxy does work (I'm using it now) I know it does connect to AIM since It works fine using AdiumX.
    Here are my settings:
    (Checked) Connect using proxy
    (Unchcecked) User System Preferences
    Server: 127.0.0.1
    Port: 1080 Protocol: Socks 5
    Username: (blank)
    Password: (blank)
    It works fine on Safari, AdiumX, & X-Chat Aqua... Just not iChat
    When I connect i get this:
    Could not connect to AIM
    The AIM proxy refused the connection. Check the proxy information in the Accounts section of iChat preferences.

    I am having this very same problem; similar environment. I have a SOCKS4 proxy that I know works with other connections, including a "generic" AIM account. Anybody have any ideas?

  • AnyConnect options as SOCKS proxy not supported....??

    Hi Guys
    So we are planning to migrate away from IPEC vpn and use AnyConnect, however we currently have in place SquiD proxy and are using SOCKS proxy too.
    Having read the document here
    http://www.cisco.com/en/US/products/ps8411/products_qanda_item09186a00809aec31.shtml
    It seems like AnyConenct is not compatable with SOCKS proxy and having undergone testing my question now is what is the best method in getting a similar "SOCKS" tunnel over the anyconnect client?
    Kind Regards
    Mohamed

    Ok i've made a work around that will use local forwards instead of dynamic forwards and i've made an apple script that will switch all the settings for me.
    set buttonTunnel to "Tunnel"
    set buttonNormal to "Normal"
    set result to display dialog "hey" buttons {buttonTunnel, buttonNormal}
    set theButton to button returned of result
    if theButton is equal to buttonTunnel then
    tell application "Mail"
    tell account "MainAccount"
    set server name to "localhost"
    set port to 1110
    set uses ssl to false
    end tell
    set smtp server of account "MainAccount" to smtp server "localhost:UserNAME"
    tell account "SecondAccount"
    set port to 1111
    set server name to "localhost"
    end tell
    set smtp server of account "SecondAccount" to smtp server "localhost:UserNAME"
    end tell
    else
    tell application "Mail"
    tell account "MainAccount"
    set server name to "mail.MainAccount.com"
    set port to 995
    set uses ssl to true
    end tell
    set smtp server of account "MainAccount" to smtp server "mail.MainAccount.com.au:UserNAME"
    tell account "SecondAccount"
    set port to 110
    set server name to "mail.SecondAccount.net"
    end tell
    set smtp server of account "SecondAccount" to smtp server "mail.MainAccount.com.au:UserNAME"
    end tell
    end if

  • Mac Book Pro 13 inch Problem with Internet hardware and proxy servers.

    Hi im from Nicaragua,Managua and my MacBook Pro 13 inch is telling me that I dont have Hardware install for the internet so i cant connect to the Internet, However some time I can connect like weird times but like in a hour the proxy servers that im in dissconnect them self and I cant play with other computer in a lan or all around the world servers.
    Please Help me And however I dont know my garantee but here is my serial number: C1******TY3
    Thanks If you help me.
    <Personal Information Edited by Host>

    I think your computer needs to be repaired. Take it to an authorized service facility in your country.

  • Problems with the Proxy Programme--Please help

    Hi All,
    I have written a simple proxy server in the form of a servlet. I changed the proxy config of my browser to connect to this servlet hosted on the default context(http://localhost:8080) of the Tomcat 5.0.25 . Well , this servlet internally connects to the proxy of the corporate LAN . The logic that I have applied is as follows. The servlet gets the request from the client (ie the browser in this case) , extracts the headers and contents from the request, sets them to a new request that it forms and finally send this new request to the proxy. When the proxy responds, the servlet collects the response headers and contents adn writes them in its response. To sum up , this servlet transparently carries the requests and responses between the client(browser) and the corporate LAN proxy. Now the problem is this. Let's say , now I am accessing http://www.google.com.The browser sends a request to my servlet with the following headers as they are extracted by my servlet.
    ProxyServer:::>posting request
    ProxyServer:::>headerValue::> headerName = accept : headerValue=*/*
    ProxyServer:::>headerValue::> headerName = referer : headerValue=http://www.google.com/
    ProxyServer:::>headerValue::> headerName = accept-language : headerValue=en-us
    ProxyServer:::>headerValue::> headerName = proxy-connection : headerValue=Keep-Alive
    ProxyServer:::>headerValue::> headerName = user-agent : headerValue=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; UB1.4_IE6.0_SP1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
    ProxyServer:::>headerValue::> headerName = host : headerValue=www.google.com
    ProxyServer:::>headerValue::> headerName = cookie : headerValue=PREF=ID=1be27c0a74f198ca:TM=1082058853:LM=1082058853:S=bu6ORrygzm8AUkm8
    ProxyServer:::>postRequest
    I set these headers into a new connection opened to the proxy and post a fresh request to the proxy,which, in turn responds with the following headers.
    ProxyServer:::>posted request successfully
    ProxyServer:::>writing response
    ProxyServer:::>writeResponse-->headerName = Proxy-Connection : headerValue = [close]
    ProxyServer:::>writeResponse-->headerName = Content-Length : headerValue = [257]
    ProxyServer:::>writeResponse-->headerName = Date : headerValue = [Tue, 13 Jul 2004 14:01:40 GMT]
    ProxyServer:::>writeResponse-->headerName = Content-Type : headerValue = [text/html]
    ProxyServer:::>writeResponse-->headerName = Server : headerValue = [NetCache appliance (NetApp/5.5R2)]
    ProxyServer:::>writeResponse-->headerName = Proxy-Authenticate : headerValue = [Basic realm="Charlotte - napxyclt2"]
    ProxyServer:::>writeResponse-->headerName = null : headerValue = [HTTP/1.1 407 Proxy Authentication Required]
    ProxyServer:::>writeResponse exiting
    ProxyServer:::>wrote response successfully
    I write these headers back to the client. According to what I was thinking, the client ie the browser would open a new dialog box asking for username/password owing to the presence of the "Proxy-Authenticate " header. But it does not happen that way. Rather the browser stops responsding and displays a blank page. Does anyone know why it happens this way? I am pasting the server prog below for everybody's reference.
    package server.proxy;
    //import all servlet related classes
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import server.resources.*;
    //My Proxy server --->Currently it is very simplea and relies on
    //other proxy servers of an already connected network.
    public class ProxyServer extends HttpServlet
    //stores the resource bundle
    private ServerResBundle resBundle = null;
    //checks for the mode of operation
    private boolean proxySet = false;
    private String proxy = null;
    //storing the original System out/err etc
    private PrintStream sysOutOrig = null;
    private PrintStream sysErrOrig = null;
    private InputStream sysInOrig = null;
    //initialise certain features that are required later
    public void init() throws ServletException
    try
    //initialise the resource bundle
    this.initResBundle();
    System.out.println("ProxyServer:::>res bundle init");
    //set the mode of operation
    this.setMode();
    System.out.println("ProxyServer:::>mode set");
    //set the system out and err --System.setOut etc
    this.setSystemOutErr();
    System.out.println("ProxyServer:::>in/out/err set");
    }//End try
    catch(Exception e)
    System.out.println("Exception in init..."+(e.getMessage()));
    throw new ServletException(e);
    }//Edn
    catch(Throwable e)
    System.out.println("Irrecoverable Error...");
    throw new ServletException(e);
    }//End
    }//End init
    //method to init the resource bundle;
    private void initResBundle()
    this.resBundle = ServerResBundle.getBundle();
    }//End
    //method to set the mode of the server--proxy or direct
    private void setMode()
    //read the target proxy property from the bundle and
    //if it is set,take that URL
    String temp = (String)(this.resBundle.getResource(ResKeys.PROXY_SERVER));
    if ( (temp != null) && (temp.length() > 0) )
    this.proxySet = true;
    this.proxy = temp;
    temp = null;
    }//End
    }//End
    //method to set the system out and err etc
    private void setSystemOutErr() throws Exception
    //keep a copy of the original system out and error
    this.sysOutOrig = System.out;
    this.sysErrOrig = System.err;
    try
    //read the options adn if they are set, take the values directly
    String newOutStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_OUT));
    String newErrStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_ERR));
    if ((newOutStr != null) && (newOutStr.length() > 0))
    System.setOut(new PrintStream(new FileOutputStream(new File(newOutStr),true),true));
    }//End if
    if ((newErrStr != null) && (newErrStr.length() > 0))
    System.setErr(new PrintStream(new FileOutputStream(new File(newErrStr),true),true));
    }//End if
    }//End
    catch(Exception e)
    //restore the stuff
    System.setOut(this.sysOutOrig);
    System.setErr(this.sysErrOrig);
    }//End
    }//End
    //this is where the proxy functionalities will be embedded
    public void service(HttpServletRequest req,HttpServletResponse resp)
    throws ServletException,java.io.IOException
    //conenction URL
    URL target = null;
    //conenction to the remote object
    URLConnection targetConn = null;
    //stores the OOS and the OIS
    ObjectOutputStream oos = null;
    ObjectInputStream ois = null;
    try
    //check for the mode of operation
    if (proxySet)
    URLConnection objects go through two phases: first they are created, then they are connected.
    After being created, and before being connected, various options can be specified
    (e.g., doInput and UseCaches). After connecting, it is an error to try to set them.
    Operations that depend on being connected, like getContentLength, will implicitly perform the connection,
    if necessary.
    //for the URL to the proxy
    target=new URL(this.proxy);
    //conenct to the proxy
    targetConn = target.openConnection();
    //set the details of the connectuon
    targetConn.setDoInput(true);
    targetConn.setDoOutput(true);
    targetConn.setUseCaches(false);
    // If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog. If false, then no user interaction is allowed
    targetConn.setAllowUserInteraction(true);
    //connect to the remote object
    // targetConn.connect();//call this only when all the request properties are set
    System.out.println("ProxyServer:::>posting request");
    //post the received request to the URL
    this.postRequest(targetConn,req);
    System.out.println("ProxyServer:::>posted request successfully");
    System.out.println("ProxyServer:::>writing response");
    //receive the response
    //write the received response to the client
    this.writeResponse(targetConn,resp);
    System.out.println("ProxyServer:::>wrote response successfully");
    }//End if
    else
    //currently this functionality is not supported
    throw new ServletException(
    (String)(this.resBundle.getResource(ResKeys.ERR_FUNC_NOTSUPPORTED)));
    }//End
    }//End try
    catch(Exception e)
    if(e instanceof ServletException)
    throw (ServletException)e;
    }//End
    if (e instanceof IOException)
    throw (IOException)e;
    }//End
    //wrap it up in ServletException
    throw new ServletException(e);
    }//End
    }//End
    //method to write the response back to the client
    private void writeResponse(URLConnection targetConn,HttpServletResponse resp)
    throws ServletException
    //get all the header fields from the response connection and set them to the
    //response of the servlet
    Map headerFields = null;
    Iterator headerFieldEntries = null;
    Map.Entry header = null;
    //stores the input stream to the conn
    BufferedReader brConn = null;
    //stores the writer to the response
    PrintWriter prResp = null;
    //checks if the proxy authentication needed or not
    boolean proxyAuthReqd = false;
    try
    //juste ensuring that the proxy authentication is reset
    proxyAuthReqd = false;
    if( (targetConn != null) && (resp != null) )
    //Returns an unmodifiable Map of the header fields.
    //The Map keys are Strings that represent the response-header field names.
    //Each Map value is an unmodifiable List of Strings that represents the corresponding
    //field values
    headerFields = targetConn.getHeaderFields();
    //Returns a set view of the mappings contained in this map
    Set temp = headerFields.entrySet();
    //Returns an iterator over the elements in this set
    headerFieldEntries = temp.iterator();
    if (headerFieldEntries != null)
    while (headerFieldEntries.hasNext())
    Object tempHeader = headerFieldEntries.next();
    if (tempHeader instanceof Map.Entry)
    header = (Map.Entry)tempHeader;
    Object headerName = header.getKey();
    Object headerValue=header.getValue();
    System.out.println("ProxyServer:::>writeResponse-->headerName = "+headerName+" : headerValue = "+headerValue);
    //do not select the key-value pair if both the key adn the value are null
    if ( ( headerName == null) && (headerValue == null) )
    continue;
    }//Enmd
    if (headerValue != null)
    List headerValList = null;
    if (headerValue instanceof List)
    headerValList = (List)headerValue;
    }//End
    if(headerValList != null)
    for (int i=0;i<headerValList.size();i++)
    Object headerValueStr = headerValList.get(i);
    if (headerValueStr instanceof String)
    //note that the header-key can not be null for addHeader
    //I have made this temporary provision to make the programme work.
    resp.addHeader(( (headerName==null)? ("null_header"+i) :(String)headerName),
    (String)headerValueStr);
    //check if the proxy authentication required or not
    if (((String)headerValueStr).
    indexOf(resp.SC_PROXY_AUTHENTICATION_REQUIRED+"") != -1)
    System.out.println("ProxyServer:::>writeResponse-->proxy auth needed");
    //proxy authentication is needed
    proxyAuthReqd = true;
    }//End
    }//Ednd of
    else if (headerValueStr == null)
    resp.addHeader(( (headerName==null)? null :(String)headerName),
    null);
    }//End
    }//End for
    }//End if
    }//End if
    }//End
    }//End while
    }//End if
    //get the writer to the client
    prResp = resp.getWriter();
    System.out.println("ProxyServer:::>writeResponse-->proxyAuthReqd="+proxyAuthReqd);
    //juste test a simple header
    System.out.println("Proxy-Authenticate = "+(resp.containsHeader("Proxy-Authenticate")));
    //if the proxy asks you for authentication,pass on the same to the client
    //from whom you have received the request.When this flag is true,the connection
    //is closed by the remotehost adn hence any attempt to open in input steram
    //results in an error ie IOException
    if (!proxyAuthReqd)
    //now get the content adn write it to the response too
    brConn = new BufferedReader(new InputStreamReader(
    targetConn.getInputStream()));
    String tempStr = null;
    while ((tempStr = brConn.readLine())!=null)
    prResp.println(tempStr);
    }//End while
    //close the connections
    brConn.close();
    }//End if
    else
    prResp.println("Proxy Authentication needed...");
    }//End
    //close the streams
    prResp.flush();
    prResp.close();
    }//End if
    System.out.println("ProxyServer:::>writeResponse exiting\n");
    }//End try
    catch(Exception e)
    throw new ServletException(e);
    }//End
    }//End
    //method to post request to the internet
    private void postRequest(URLConnection targetConn,HttpServletRequest req)
    throws ServletException
    //extract the header parameters and the body content from the incoming request
    //and set them to the new connection
    Enumeration reqHeaders = null;
    //reads the incoming request's content
    BufferedReader brReqRd = null;
    PrintWriter prResWt = null;
    //stores temp header names and values
    String headerName = null;
    String headerValue = null;
    try
    if( (targetConn != null) && (req != null) )
    reqHeaders = req.getHeaderNames();
    //extract a header adn set it to the new connection
    while (reqHeaders.hasMoreElements())
    headerName = (String)(reqHeaders.nextElement());
    headerValue = req.getHeader(headerName);
    targetConn.setRequestProperty(headerName,headerValue);
    System.out.println("ProxyServer:::>headerValue::> headerName = "+headerName+" : headerValue="+headerValue);
    }//End
    System.out.println("ProxyServer:::>postRequest\n");
    //establis the actual connection
    //calling this method bfore the above loop results in IllegalStateException
    targetConn.connect();
    //NOTE : try reading from and writing into OIS and OOS respectively
    //now read the contents and write them to the connection
    // brReqRd = req.getReader(); //this hangs for some reason
    brReqRd = new BufferedReader(new InputStreamReader(req.getInputStream()));
    System.out.println("Got the reader..brReqRd = "+brReqRd);
    if (brReqRd != null)
    String temp = null;
    //establish the printwriter
    // prResWt = new PrintWriter(targetConn.getOutputStream(),true);
    prResWt = new PrintWriter(targetConn.getOutputStream());
    System.out.println("trying to read in a loop from brReqRd.. ready="+(brReqRd.ready()));
    while( (brReqRd.ready()) && ((temp=brReqRd.readLine()) != null) )
    System.out.println("In while::>temp = "+temp);
    prResWt.println(temp);
    }//Emd while
    //close the streams adn go back
    brReqRd.close();
    prResWt.flush();
    prResWt.close();
    }//End
    }//End outer if
    System.out.println("ProxyServer:::>postRequest exiting\n");
    }//End try
    catch(Exception e)
    throw new ServletException(e);
    }//End
    }//End
    }//End

    Hi serlank ,
    Thanks for your reply. Well , I initially I thought of not pasting the code,as it was too long. But I could not help it,as I thought I must show in code what I exactly meant. That's why I followed a description of my problem with the code. You could probably have copied the code and pasted it in one of your favourite editors to take a look at it. Did you,by any chance, try to read it on the browser? And as regards reposting the same message, I can say that I did it as I felt the subject was not quite appropriate in the first posting and I was not sure as to how I could delete/alter the posting. I am not asking for a code-fix,but some suggestions from some one who might ever have come across such a thing.Anyway, lemme know if you have any idea on it. Thanks...

  • Problems with IIS proxy to cluster

              We are using WebLogic 6.1 with two managed servers in a cluster. Our IIS server
              is running IIS 4 and is set up to proxy to the cluster by IP addresses. When
              one server goes down(as in a hardware failure or shut down), the other server's
              queue loads up with unprocessed requests causing our web application to "freeze".
              No errors are logged anywhere. The only way to free up the WL server (and stop
              the queue from growing) is to reboot both the application server (to clear the
              queu)AND the IIS web server(to stop the requests). Is there a known problem with
              the WL IIS plug-in DLL that could cause these errant requests? or.. Does this
              point to a specific error on our IIS server? or.. Is there a bad setting somewhere
              that can be changed to prevent this? Please Advise!
              

    Hello,
    From this it looks like you may be able to use PathPrepend to jimmy your URLs:
    PathPrepend : String that the plug-in prepends to the beginning of the original URL, after PathTrim is trimmed and before the request is forwarded to WebLogic Server.
    I would suggest it may be a good idea to have a seperate webserver for your production domain. In most places I have worked in every platform is configuered with its own resources e.g staging server has its own webserver and db. This affords the people that use those envrionments greater isolation.

  • Running windows 7 firefox refuses to come up, proxy server is refusing connections network adminiastrater says proxy servers are correct and is issue with firefox what do I do/ do

    I start up firefox and it says the proxy server is refusing connection. It is configured to use a proxy server that is refusing connections. To check the proxy servers and ask network administrater to make sure proxy server is correct They say the proxy server is correct and it is a firefox problem. So what to I do now?

    Make sure that the Firefox connection settings are the same as in IE.
    You can find the connection settings in "Tools > Options > Advanced : Network : Connection"
    If you do not need to use a proxy to connect to internet then select No Proxy
    In Firefox 3.6.4 and later the default connection settings have been changed to "Use the system proxy settings".
    You can compare them with the IE settings in the Internet Options (Control Panel).
    Control Panel > Internet Options > Connections: LAN Settings

  • Connecting to Wireless Network with domain name and proxy servers?

    Hi,
    I'm trying to connect to the wireless network at my college, however it's not as straight forward as usual... The network is hidden, although I know to 'Join other network' and type in the SSID of the network and then set the authentication method to WPA-Enterprise. However, this is where I run into a problem..
    To connect, I need to 'configure encryption as AES', which I'm not sure how to do on OS X. Furthermore, after signing in with my college ID I am required to 'Use the domain name [domain name]' and 'configure your browser to use the college proxy servers [example.example.net] on port [123]
    Any help on this would be greatly appreciated as it's important that I log on to the network for work etc.
    Thanks very much for your time.

    johnthompson1993 wrote:
    Hi,
    To connect, I need to 'configure encryption as AES', which I'm not sure how to do on OS X. Furthermore, after signing in with my college ID I am required to 'Use the domain name [domain name]' and 'configure your browser to use the college proxy servers [example.example.net] on port [123]
    The encryption should be configured automatically. To use the proxy:
    1. Open System Preferences
    2. Click on Network
    3. Select Airport from the list on the left
    4. Click on Advanced, near the bottom right
    5. One of the tabs will be called Proxy. Configure your settings there.

  • Intermittent proxy error "There is a problem with the proxy server's security certificate. Outlook is unable to connect to the proxy server "

    Hi all,
    From time to time (at least once a day), the following message pops up on the user's screen:
    "There is a problem with the proxy server's security certificate. Outlook is unable to connect to the proxy server . Error Code 80000000)."
    If we click "OK" it goes away and everything continues to work although sometimes Outlook disconnects. It is quite annoying...
    Any ideas?
    Thank you in advance

    Hi,
    For the security alert issue, I'd like to recommend you check the name in the alert windows, and confirm if the name is in your certificate.
    Additionally, to narrow down the cause, when the Outlook client cannot connect again, I recommand you firstly check the connectivity by using Test E-mail AutoConfiguration. For more information, you can refe to the following article:
    http://social.technet.microsoft.com/Forums/en-US/54bc6b17-9b60-46a4-9dad-584836d15a02/troubleshooting-and-introduction-for-exchange-20072010-autodiscover-details-about-test-email?forum=exchangesvrgeneral
    Thanks,
    Angela Shi
    TechNet Community Support

  • There is a problem with the proxy server's security certificate. The name on the security certificate is invalid or does not match the name of the target site "Mailserver"

    Good day Guys
    First of all I am not an Exchange Expert, and I might be asking a very stupid question, but please bare with me. :) 
    While I was on leave our Mail server fell over and The company got a Specialist to help out for the time being.
    We where\are on Microsoft Exchange 2007 , which Fell over, and the specialist was able to recover as much data as he could.
    They then installed Exchange 2013 and tried to migrate everything from 2007 to 2013 and not everything migrated over.
    But the problem is, Outlook Anywhere was enable on 2007 and worked a 100% (before the disaster)
    With Exchange 2013 I get the following error message when trying to connect With Outlook 2013, using an external connection:
    "There is a problem with the proxy server's security certificate. The name on the security certificate is invalid or does not match the name of the target site "Mailserver"
    Outlook is unable to connect to the Proxy server. (Error Code 0)"
    Has anyone had the Similar when migrating over from 2007 to 2013 or is this an Issue on IIS and nothing to do with Exchange migration?
    Your assistance will be greatly appreciated.

    Hi,
    Firstly, I would suggest we use Exchange 2013 FE as the Outlook Anywhere proxy server.
    For the certificate issue, it mostly occurs because the host name that Outlook are trying to access does not match the certificate SAN. Please check with this point. If they do not match, you
    can change the host name by referring to the following article:
    https://support.microsoft.com/kb/940726/en-us?wa=wsignin1.0
    Thanks,
    Simon Wu
    TechNet Community Support

  • Arch as a router... through a socks proxy

    I have my arch box acting as a gateway on my local network, is it possible to tunnel all the traffic that goes through the box through a socks proxy?
    I want to be able to proxy things like my phone and xbox
    Thanks!

    You want to utilize an upstream SOCKS proxy? I doubt it, you'd be better off setting up a VPN and routing your outbound traffic through that.

  • Problem with discovering Managed Servers

    Hi,
    I got problem with discovering managed servers, when I restart only administration
    server while managed servers are running. During restart of admin server everything
    seems to be ok (the directive: Starting discovery of managed server... appears
    on the screen).
    However when I start admin console through http, I cannot monitor performance,
    browse logs etc. I can only shutdown managed server and I can see in a server
    tag that particular managed servers are running.
    I'm looking forward for any clues
    Michal

    Sorry,
    i cannot stop those managed server - in Control tab I have active only option
    to start those server but they are running. In logging tab when I want to browse
    the log the message that probably this server is not running appear. However in
    the tab when all servers are listened there is a message that they are running
    "Michal" <[email protected]> wrote:
    >
    Hi,
    I got problem with discovering managed servers, when I restart only administration
    server while managed servers are running. During restart of admin server
    everything
    seems to be ok (the directive: Starting discovery of managed server...
    appears
    on the screen).
    However when I start admin console through http, I cannot monitor performance,
    browse logs etc. I can only shutdown managed server and I can see in
    a server
    tag that particular managed servers are running.
    I'm looking forward for any clues
    Michal

Maybe you are looking for

  • BP number in GL Line Item Report

    Hello Gurus, Is there a way to view BP number in GL Line Item Report FBL3N ? I went through the dynamic selection, but didn't see any option for BP. My client wants to see BP info in certain GL accounts without referring back to treasury transactions

  • Need to link MM & SD

    Hii, My client secenarios is, my client is in services business,he is wroking as a trader, He buy good from seller with some price (agreement is made for certains period ) & then sell to buyer with some other price(agreement is made), So he want to l

  • Loop in workflow

    hi friends    How to use a loop in workflow. When ever i placed a loop after a activity step the end of the loop points to the next step, but i want the end of the loop should place at the begining of the activity. how to drag the point and place it

  • EHS - List: weight of product's substances

    Hello, I'm completely new to EH&S module. My company has to produce for every shipped product and/or packaging, a weight list of substances it's composed from. Example product X is composed of: category metals: Iron x kg, cadmium y kg, ... category p

  • Photoshop CS6 / Scanner Software

    We are using Photoshop CS6 (Windows 8, 64 Bit) + Epson Perfection 3200 Scanner. Please, can you recommend a scanning Software for our work? Probably there is a software on the market with a Photoshop plug in? Thanks in advance for your help an inform