Hi Madhawa,
Method [3] is used to generate the feign client in the APIM integration
client which publishes the APIs. Can we try to modify this method as
follows to support proxy capabilities? I believe this method is better than
forking the feign repo.
public static Client getSSLClient() {
boolean isIgnoreHostnameVerification =
Boolean.parseBoolean(System.getProperty("org.wso2.ignoreHostnameVerification"));
OkHttpClient okHttpClient;
String proxyHost = System.getProperty("http.proxyHost");
String proxyPort = System.getProperty("http.proxyPort");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new
InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));
if(isIgnoreHostnameVerification) {
okHttpClient = new OkHttpClient.Builder()
.sslSocketFactory(getSimpleTrustedSSLSocketFactory())
.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}).proxy(proxy).build();
return okHttpClient;
}else {
okHttpClient = new
OkHttpClient.Builder().sslSocketFactory(getTrustedSSLSocketFactory()).proxy(proxy).build();
return okHttpClient;
}
}
[3] -
https://github.com/wso2/carbon-device-mgt/blob/master/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/Utils.java#L76
Thanks,
Madawa
On Wed, Mar 21, 2018 at 11:31 AM, Madhawa Perera <[email protected]> wrote:
> Hi Thusitha,
>
> I saw this GitHub issue and did the fix on Feign client instead of using
> okhttp client. Fix worked as in my previous comment.
> But we will try OkHttpClient.Builder() as well.
>
> Thank you
> Best Regards,
> Madhawa
>
> On Wed, Mar 21, 2018 at 2:11 AM, Thusitha Thilina Dayaratne <
> [email protected]> wrote:
>
>> Hi Madhawa,
>>
>> I think you can refer to [1] and [2]. Basic idea is to use okhttp client
>> inside the feign instead of feign default client.
>>
>> [1] - https://github.com/OpenFeign/feign/issues/370
>> [2] - https://github.com/OpenFeign/feign/tree/master/okhttp
>>
>> Thanks
>> Thusitha
>>
>> On Tue, Mar 20, 2018 at 11:45 PM, Madhawa Perera <[email protected]>
>> wrote:
>>
>>> Hi Rasika,
>>>
>>> Yes, I tried this [2] with a slight modification. It seems working.
>>> Need to modify the nonProxyHost check to be compatible with multiple
>>> hostnames. That is nonProxyHost can hold multiple values like
>>> "localhost|127.0.0.1".
>>>
>>> [2] https://github.com/madhawap/feign/commit/4aebf954e730cbeb4fd
>>> 8c58b95c8d455ab857747
>>>
>>> Thank you
>>> Best Regards,
>>> Madhawa
>>>
>>> On Tue, Mar 20, 2018 at 6:07 PM, Rasika Perera <[email protected]> wrote:
>>>
>>>> Hi Madhawa,
>>>>
>>>> Have you tried forking Feign client? Seems there's a fix[1] for the
>>>> issue of HTTP Proxy. Can you try it as well?
>>>>
>>>> [1] https://github.com/rhudson/feign/commit/5d611d7bcb767a26
>>>> c06bffdc396f256d02dca353
>>>>
>>>> On Tue, Mar 20, 2018 at 5:41 PM, Madhawa Perera <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Devs,
>>>>>
>>>>> It seems that Feign isn't routing traffic through a configured proxy.
>>>>> I'm using Feign version 9.3.1
>>>>> Is there any way to route Feign traffic through an HTTP proxy server?
>>>>>
>>>>> I set VM args: -Dhttp.proxyHost and -Dhttp.proxyPort yet Feign seems
>>>>> not using these configurations. From looking at Feign.Client [1] there is
>>>>> no option to pass through a Proxy.
>>>>>
>>>>> Is there any way that we can overcome this restriction?
>>>>>
>>>>> [1] https://github.com/OpenFeign/feign/blob/9.3.1/core/src/m
>>>>> ain/java/feign/Client.java#L77
>>>>>
>>>>> Thank you
>>>>> Best Regards,
>>>>> Madhawa
>>>>>
>>>>> --
>>>>> Madhawa Perera | Software Engineer
>>>>> WSO2, Inc | lean. enterprise. middleware.
>>>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>>>> <https://maps.google.com/?q=20,+Palm+Grove,+Colombo+03,+Sri+Lanka&entry=gmail&source=g>
>>>>> Mobile: +94 (0)77 365 5496 <+94%2077%20365%205496> | Work: +94 11 214
>>>>> 5345
>>>>> Email: [email protected] | Web: www.wso2.com
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> With Regards,
>>>>
>>>> *Rasika Perera*
>>>> Senior Software Engineer
>>>> Blogs: medium.com/@rasikaperera, tiriboy.blogspot.com
>>>> PGP Key: 56E03A48
>>>> LinkedIn: http://lk.linkedin.com/in/rasika90
>>>>
>>>> <http://wso2.com/signature>
>>>>
>>>> WSO2 Inc. www.wso2.com
>>>> lean.enterprise.middleware
>>>>
>>>
>>>
>>>
>>> --
>>> Madhawa Perera | Software Engineer
>>> WSO2, Inc | lean. enterprise. middleware.
>>> #20, Palm Grove, Colombo 03, Sri Lanka
>>> <https://maps.google.com/?q=20,+Palm+Grove,+Colombo+03,+Sri+Lanka&entry=gmail&source=g>
>>> Mobile: +94 (0)77 365 5496 <077%20365%205496> | Work: +94 11 214 5345
>>> Email: [email protected] | Web: www.wso2.com
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Thusitha Thilina Dayaratne*
>> PhD Student - Cybersecurity Lab
>> Monash University
>>
>>
>
>
> --
> Madhawa Perera | Software Engineer
> WSO2, Inc | lean. enterprise. middleware.
> #20, Palm Grove, Colombo 03, Sri Lanka
> Mobile: +94 (0)77 365 5496 <+94%2077%20365%205496> | Work: +94 11 214
> 5345
> Email: [email protected] | Web: www.wso2.com
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
--
Madawa Soysa / Software Engineer
[email protected] / +94714616050
*WSO2 Inc.*
lean.enterprise.middleware
<https://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev