Open depsypher opened 8 years ago
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
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.
@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.
Note:
Consider replacing with https://github.com/google/google-http-java-client
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"?
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!
@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 https://github.com/sendgrid/sendgrid-java/issues/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?
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 I got this one.
@thinkingserious Replace does not work.
@baignomi,
Yes, you are correct. This issue is yet to be resolved. You can follow this thread for progress.
Thanks!
With Best Regards,
Elmer
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 :-)
@andy-trimble,
Is this something you still would like to tackle? Thanks!
Ah, yes @thinkingserious. I completely forgot about this one. I'll take a crack at it.
Awesome!
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.
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;
Is this still being worked on? I am currently having the same issue in Android.
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
What is the status of this issue? Does this completely stop the library working on Android?
@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.
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.
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.
Still the same problem in 2022 !!
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.