XFire

CLONE -Recognize the Java runtime system variable for HTTP proxies

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1-RC1
  • Fix Version/s: 1.2.5
  • Component/s: None
  • Labels:
    None
  • Environment:
    N/A
  • Number of attachments :
    1

Description

Currently it seems that the only way to specify a proxy for an XFire client is by doing it programatically when creating the client:

MySoap client = stub.getMySoap();
Client http = ((XFireProxy) Proxy.getInvocationHandler(client)).getClient();
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "localhost");
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080");

This means that if you want to be able to transparently set a proxy you'll have to code some logic to check whether a property is set everywhere you create a client. A much more convenient way would be if the generated code from XFire took into account the standard Java environment properties for setting a proxy (as documented here: http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html). This would provide much convenience and flexibility in how to set whether or not to use an HTTP proxy as explained here: http://www.rgagnon.com/javadetails/java-0085.html.

Activity

Hide
Steve Kwee added a comment -

I just upgraded from xfire-1.2.3 -> 1.2.4.
I have been using a proxy for debugging and performance analysis with jmeter.
I am using a jdk150_b6 and a tomcat 5.5.20

So far I have used the code above to configure the proxy but after the upgrade neither method seems to work.
The client always ignores any proxy settings

a) works with 1.2.3, broken with 1.2.4
MySoap client = stub.getMySoap();
Client http = ((XFireProxy) Proxy.getInvocationHandler(client)).getClient();
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "localhost");
http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080");

b) did not work on any version (1.2.3, 1.2.4)
-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8081
-Dhttp.nonProxyHosts=

b) did not work on any version (1.2.3, 1.2.4)
-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8081

Show
Steve Kwee added a comment - I just upgraded from xfire-1.2.3 -> 1.2.4. I have been using a proxy for debugging and performance analysis with jmeter. I am using a jdk150_b6 and a tomcat 5.5.20 So far I have used the code above to configure the proxy but after the upgrade neither method seems to work. The client always ignores any proxy settings a) works with 1.2.3, broken with 1.2.4 MySoap client = stub.getMySoap(); Client http = ((XFireProxy) Proxy.getInvocationHandler(client)).getClient(); http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "localhost"); http.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080"); b) did not work on any version (1.2.3, 1.2.4) -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8081 -Dhttp.nonProxyHosts= b) did not work on any version (1.2.3, 1.2.4) -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8081
Hide
Tomasz Sztelak added a comment -

Can you tell me how exactly your env is configured ( client, jmeter, server ) ? I'll try to reproduce the same situation.

Show
Tomasz Sztelak added a comment - Can you tell me how exactly your env is configured ( client, jmeter, server ) ? I'll try to reproduce the same situation.
Hide
Steve Kwee added a comment -

The client is generated with xfire and uses the same JDK as the server: jdk150_b6
JMeter Version is 2.2.

The server (tomcat 5.5.20) is listening on localhost port 8080
The proxy is listening on localhost port 8081 (There is a typo in my last comment, 8081 is correct)
Everything is running in a eclipse 3.2-WTP-Environment.

As stated above, I just implemented the proxy feature for jmeter on thursday and
have recorded wonderful traces. On friday I did the upgrade to version 1.2.4 and the
proxy feature broke.

If you can tell me in which part of the code the decision to use a proxy or not is taken,
I could try to debug it myself.

Show
Steve Kwee added a comment - The client is generated with xfire and uses the same JDK as the server: jdk150_b6 JMeter Version is 2.2. The server (tomcat 5.5.20) is listening on localhost port 8080 The proxy is listening on localhost port 8081 (There is a typo in my last comment, 8081 is correct) Everything is running in a eclipse 3.2-WTP-Environment. As stated above, I just implemented the proxy feature for jmeter on thursday and have recorded wonderful traces. On friday I did the upgrade to version 1.2.4 and the proxy feature broke. If you can tell me in which part of the code the decision to use a proxy or not is taken, I could try to debug it myself.
Hide
Tomasz Sztelak added a comment -

The problem can be caused by new code used to determine noproxyhosts :/ you can take a look at CommonsHttpMessageSender class. Maybe try to build xfire-core and xfire-java5 modules from svn and see if anything is fixed. If not, in CommonsHttpMessageSender there is variable useProxyUtils, set it to false and see if it helps.

Show
Tomasz Sztelak added a comment - The problem can be caused by new code used to determine noproxyhosts :/ you can take a look at CommonsHttpMessageSender class. Maybe try to build xfire-core and xfire-java5 modules from svn and see if anything is fixed. If not, in CommonsHttpMessageSender there is variable useProxyUtils, set it to false and see if it helps.
Hide
Steve Kwee added a comment -

The following code

Method method = clazz.getDeclaredMethod("isNonProxyHost", new Class[]{String.class});
Boolean result = (Boolean) method.invoke(proxyUtils,new Object[]{strURI});
return result.booleanValue();

returns true in any of the above configurations b), c).

The call to ps.select(uri); in ProxyUtils returns a a list with a single entry [Direct].

As I am in a debugging Environment, my server, client and proxy are all on localhost.
Maybe that causes the problem.

A patch could be to check if server and proxy are on the same host and to ignore the result
of the java.net.ProxySelector in this special case.

ProxyUtils.isNonProxyHost

String proxyHost = System.getProperty("http.proxyHost", "");
if (proxyHost.equals(uri.getHost()))
return false;

By the way:
The source for xfire-java5-1.2.4.jar is not contained in the xfire-distribution-1.2.4-sources.jar

One last question
I can see that CommonsHttpMessageSender.useProxyUtils = false suppresses the use
of ProxyUtils but how can I set this property during client creation without modifying
xfire sources ?

I have solved my problem with a workaround and a modified version of ProxyUtils.java
in my classpath.

Show
Steve Kwee added a comment - The following code Method method = clazz.getDeclaredMethod("isNonProxyHost", new Class[]{String.class}); Boolean result = (Boolean) method.invoke(proxyUtils,new Object[]{strURI}); return result.booleanValue(); returns true in any of the above configurations b), c). The call to ps.select(uri); in ProxyUtils returns a a list with a single entry [Direct]. As I am in a debugging Environment, my server, client and proxy are all on localhost. Maybe that causes the problem. A patch could be to check if server and proxy are on the same host and to ignore the result of the java.net.ProxySelector in this special case. ProxyUtils.isNonProxyHost String proxyHost = System.getProperty("http.proxyHost", ""); if (proxyHost.equals(uri.getHost())) return false; By the way: The source for xfire-java5-1.2.4.jar is not contained in the xfire-distribution-1.2.4-sources.jar One last question I can see that CommonsHttpMessageSender.useProxyUtils = false suppresses the use of ProxyUtils but how can I set this property during client creation without modifying xfire sources ? I have solved my problem with a workaround and a modified version of ProxyUtils.java in my classpath.
Hide
Steve Kwee added a comment -

Fixes problem when server and proxy are on the same host.
JVM-Args:
-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8081

Show
Steve Kwee added a comment - Fixes problem when server and proxy are on the same host. JVM-Args: -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8081
Hide
Tomasz Sztelak added a comment -

Fixed in svn.
No you can disable proxyUtils by setting CommonsHttpMessageSender.DISABLE_PROXY_UTILS client property to "true", then all host will be marked as proxied.
You can also specify your own implementation of proxyUtils with CommonsHttpMessageSender.PROXY_UTILS_CLASS like
client.setProperty(CommonsHttpMessageSender.PROXY_UTILS_CLASS ,"my.custom.proxy.utils");

Show
Tomasz Sztelak added a comment - Fixed in svn. No you can disable proxyUtils by setting CommonsHttpMessageSender.DISABLE_PROXY_UTILS client property to "true", then all host will be marked as proxied. You can also specify your own implementation of proxyUtils with CommonsHttpMessageSender.PROXY_UTILS_CLASS like client.setProperty(CommonsHttpMessageSender.PROXY_UTILS_CLASS ,"my.custom.proxy.utils");

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: