phax / peppol-commons

Java library with shared Peppol components - identifier handling, codelists, SBDH handler, SMP Client, SML Client
Apache License 2.0
29 stars 8 forks source link

NonProxyHosts support not working #10

Closed hmspider closed 7 years ago

hmspider commented 7 years ago

Error when smpclient is trying to access an SMP for which no http proxy is required (using URAC application):

05 Jan 2017 18:01:09 [http-nio-8080-exec-9] ERROR gr.uprc.connector.rest.api.SmpResource  - Could not get COMPLETE record from SMP
[...]
Caused by: com.helger.peppol.smpclient.exception.SMPClientUnauthorizedException: org.apache.http.client.HttpResponseException: Forbidden
        at com.helger.peppol.httpclient.AbstractGenericSMPClient.getConvertedException(AbstractGenericSMPClient.java:379)
        at com.helger.peppol.httpclient.AbstractGenericSMPClient.executeGenericRequest(AbstractGenericSMPClient.java:425)
        at com.helger.peppol.smpclient.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:261)
        at com.helger.peppol.smpclient.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:291)
        at gr.uprc.connector.smp.SimpleSMPCallerService.getSimpleSMPRecord(SimpleSMPCallerService.java:110)
        ... 48 more
Caused by: org.apache.http.client.HttpResponseException: Forbidden
        at com.helger.peppol.httpclient.AbstractSMPResponseHandler.handleResponse(AbstractSMPResponseHandler.java:103)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
        at com.helger.httpclient.HttpClientManager.execute(HttpClientManager.java:98)
        at com.helger.peppol.httpclient.AbstractGenericSMPClient.executeRequest(AbstractGenericSMPClient.java:352)
        at com.helger.peppol.httpclient.AbstractGenericSMPClient.executeGenericRequest(AbstractGenericSMPClient.java:421)
        ... 51 more 

smpclient.properties file:

http.proxyHost=<proxy_address>
http.proxyPort=<proxy_port>
http.nonProxyHosts=my_internal_ip|*.my.internal.domain

'External' SMP's are accessed OK.

When commenting out proxy properties above OR erasing the file, the results are the opposite: only able to access internal SMP, NOT external SMP's.

Tomcat Java properties: ubuntu 1850 3.2 43.4 3681168 889704 ? Sl 17:23 2:32 /usr/bin/java -Djava.util.logging.config.file=/home/ubuntu/apache-tomcat-8.0.39/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dhttp.proxyHost=<my_proxy_address> -Dhttp.proxyPort=<proxy_port> -Dhttp.nonProxyHosts=my_internal_ip|*.my.internal.domain

phax commented 7 years ago

Try removing/commenting the properties in the file and for startup, type quoting the parameter -Dhttp.nonProxyHosts=my_internal_ip|*.my.internal.domain like so "-Dhttp.nonProxyHosts=my_internal_ip|*.my.internal.domain" as I assume that | is a reserved character on the shell...

hmspider commented 7 years ago

When disabling proxy properties in smpclient.properties file the REST API/SMPclient is only able to access internal SMP, NOT external SMP's. Therefore unable to send messages.

The nonProxyHosts parameter was already quoted in Tomcat config file, the output above was from 'ps aux | grep tomcat' command.

Tested with quoting the parameter http.nonProxyHosts in smpclient.properties file, still same behaviour/error.

phax commented 7 years ago

And of course you called smpclient.setUseProxySystemProperties(true) in the Java code?

hmspider commented 7 years ago

Would have to confirm that with the implementer of the application that uses smpclient library - URAC (that would be Jerry)

On 7 January 2017 at 04:17, Philip Helger notifications@github.com wrote:

And of course you called smpclient.setUseProxySystemProperties(true) in the Java code?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/phax/peppol-commons/issues/10#issuecomment-271061626, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiVqkBOGZwohW0aTzFyDGS9Y0vvz40bks5rPxH1gaJpZM4Lb_-o .

phax commented 7 years ago

Works as expected?

hmspider commented 7 years ago

Indeed. Since we nailed the configuration after Jerry having released a version of URAC, featuring the 'patched' smpclient lib our Access Point has worked flawlessly behind our corporate proxy --> we just had recent feedback from our Tender System partner in this regard.

URAC is the Backend Integration ABB of our eSens/OpenPEPPOL Access Point. Besides the sending and receiving of messages from/to our eDelivery users, it offers them the much added-value capability of self-managing their published capabilities in our SMP (also sitting behind said proxy).

Kudos!

On 27 February 2017 at 11:11, Philip Helger notifications@github.com wrote:

Works as expected?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/phax/peppol-commons/issues/10#issuecomment-282692360, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiVqrVHjls6QiV0OGzG_OEPJ4hmkruNks5rgq9igaJpZM4Lb_-o .

phax commented 7 years ago

Excellent - thanks for the update!!