Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Httpcore dependency #2

Open
depsypher opened this issue May 20, 2016 · 25 comments
Open

Replace Httpcore dependency #2

depsypher opened this issue May 20, 2016 · 25 comments
Labels
difficulty: very hard fix is very hard in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@depsypher
Copy link

Issue Summary

Because sendgrid/java-http-client depends on org.apache.httpcomponents/httpcore, this library is necessary under google appengine in order to stay under socket connection quotas:
https://github.com/sendgrid/sendgrid-google-java

But it looks like that library is soon to be very out of date with the latest sendgrid apis. It would be great if java-http-client could remove that dependency and just use the built in java http connection apis directly so that the official sendgrid-java library would work in all scenarios.

@thinkingserious
Copy link
Contributor

Hello @depsypher,

Thanks for the issue!

The new, supported, library can be found here: https://github.com/sendgrid/sendgrid-java/tree/v3beta, it will be out of beta in a few weeks.

I did not see anything in the https://github.com/sendgrid/sendgrid-google-java library that deals with socket connection quotas, could you please elaborate?

We have the org.apache.httpcomponents/httpcore dependency because the java http connection apis do not support PATCH. Do you know of a work around to this? Is there another http library that would achieve your results?

With Best Regards,

Elmer

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: question question directed at the library labels May 20, 2016
@depsypher
Copy link
Author

Very interesting. I didn't know that about PATCH. I found a couple workarounds, but I'm not sure which is the better one:

https://java.net/jira/browse/JERSEY-639
http://stackoverflow.com/questions/25163131/httpurlconnection-invalid-http-method-patch

The background regarding appengine is that it's a bit of a strange beast and java code there runs on a google-modified jdk. That jdk whitelists certain classes and has custom implementations of others so that code runs safely from multiple users without interfering with each other.

Google does some special magic to HttpURLConnection so those calls run in their sandbox. That magic doesn't exist for the apache http implementation, so appengine does a socket connection instead to safely exit the sandbox. This works fine, but google imposes a limit on the number of socket connections allowed per project... so if you send a high volume of email you can blow that limit. Once you hit that quota you're pretty much SOL, as any further calls that use socket connections (be they sending emails or connections to a database) will fail until the quota resets the next day. Not fun.

Anyhow, as long as the older sendgrid-google-java code still works, it's a fine stopgap measure for us to keep using it... but if the sendgrid apis it talks to become deprecated we'll need to have an alternative that doesn't use apache httpcore at that point.

@thinkingserious
Copy link
Contributor

@depsypher,

Thanks for the detailed response! We are not deprecating the v2 version of our mail send endpoint, so you are good there.

The first link is something I have not tried, but the second does not work in my tests.

In September, Java will get an update where the HTTP core library will support PATCH. I'm hoping this will be a solid solution. We were able to use core HTTP libraries on all the other 6 languages we support and were quite surprised to run into the PATCH issue when we tried to remove the Apache dependency on this library :(

I'll leave this issue open for further investigation, so yes, your stop gap solution should be fine. Just please be careful when making any updates.

  • Elmer

@thinkingserious
Copy link
Contributor

@thinkingserious
Copy link
Contributor

Note:

Consider replacing with https://github.com/google/google-http-java-client

@thinkingserious thinkingserious changed the title Httpcore dependency Replace Httpcore dependency Apr 29, 2017
@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap and removed type: question question directed at the library labels Apr 29, 2017
@dougouk
Copy link

dougouk commented May 28, 2017

EDIT: nvm, I see that this is an on-going issue.

The link https://github.com/sendgrid/sendgrid-java/tree/v3beta no longer works.

Is there a fix for this?

Is the fix "replacing with https://github.com/google/google-http-java-client"?

@thinkingserious
Copy link
Contributor

Hi @dougouk,

I believe the fix is to replace the http client with the google-http-java-client. Unless the native Java client has caught up.

In any case, I've added your vote to this issue to help increase it's priority.

Thanks!

@dougouk
Copy link

dougouk commented May 28, 2017

@thinkingserious

I tried replacing the http client, but it didn't fix the issue.

The SendGrid API looks for the http client, not the google-http-java-client in the code, so replacing it doesn't fix the issue.

I am actually more specifically here for the following closed issue sendgrid/sendgrid-java#127 but the issue redirects me to this thread.

All I'm trying to do is simply send an email using SendGrid on Android, but I can't due to the dependency issues

Is there a solution?

@thinkingserious
Copy link
Contributor

I apologize for not being clear. This is an open issue. We need to actually replace the current client with the google-http-java-client. It will not be as simple as just replacing the client, I don't think. I believe the google-http-java-client probably has a different interface to the apache http client.

@thinkingserious thinkingserious added the difficulty: very hard fix is very hard in difficulty label Oct 1, 2017
@andy-trimble
Copy link
Contributor

@thinkingserious I got this one.

@thinkingserious thinkingserious added the status: work in progress Twilio or the community is in the process of implementing label Oct 12, 2017
@baignomi
Copy link

@thinkingserious
Replace does not work.

@thinkingserious
Copy link
Contributor

@baignomi,

Yes, you are correct. This issue is yet to be resolved. You can follow this thread for progress.

Thanks!

With Best Regards,

Elmer

@maelcaldas
Copy link

Hi Elmer, do you have an ETA for this issue? This is the only thing that is blocking us from moving our mail infrastructure to SendGrid... Thanks :-)

@thinkingserious
Copy link
Contributor

@andy-trimble,

Is this something you still would like to tackle? Thanks!

@andy-trimble
Copy link
Contributor

Ah, yes @thinkingserious. I completely forgot about this one. I'll take a crack at it.

@thinkingserious
Copy link
Contributor

Awesome!

@bashoogzaad
Copy link

What is the status for this fix? I am also using App Engine and running into the same issue. I am using my own http utils in App Engine for now, but would love to use this library.

@szeidner
Copy link

I am also curious what the status of this issue is. I just tried to create a SendGrid instance in Android and got:
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier;

@Glennmen
Copy link

Is this still being worked on? I am currently having the same issue in Android.

@walker142
Copy link

Hi there, I was just wondering if this issue is still being worked on as I am currently experiencing the same issue, or is there even a work around for the time being to get my Android app to send an email? Thanks

@johnnyzen
Copy link

What is the status of this issue? Does this completely stop the library working on Android?

@childish-sambino
Copy link
Contributor

@johnnyzen As far as I know, it's not currently being worked on. The original request was to allow for better usage within Google App Engine; not Android even though a fix may impact both.

That said, interacting with SendGrid APIs that require auth is not recommended from a client/app/browser. Doing so requires potentially exposing credentials to the end user. The APIs should be invoked by a backend service which could be supporting the front-end client. What's your use case for needing this to be available on Android? There may be edge cases I'm not considering here so just trying to get some clarity.

@childish-sambino childish-sambino added status: help wanted requesting help from the community and removed status: work in progress Twilio or the community is in the process of implementing labels Mar 13, 2020
@vmfox
Copy link

vmfox commented Apr 26, 2020

Is there any (simple) solution at this point?

I have already spent/wasted 2 days trying to integrate SendGrid into my app and every single time it either fails because of the:
java.lang.NoSuchFieldError: No static field INSTANCE of type org/apache/http/conn/ssl/AllowAllHostnameVerifier; #588

or the duplication of libraries, or something else. This is particularly frustrating and with the issue first reported more than 3 years ago, I couldn't find a straightforward "just works" solution as of now.

@digsub
Copy link

digsub commented May 31, 2020

After appeasing a build exception due to More than one file was found with OS independent path 'META-INF/DEPENDENCIES' in my issue #625, I'm now also stuck with java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier

Misery loves company.

@yamanjain
Copy link

Still the same problem in 2022 !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: very hard fix is very hard in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests