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

Sendgrid client doesn't close TCP connection properly #165

Closed
bidhanadh opened this issue Oct 25, 2016 · 1 comment · Fixed by sendgrid/java-http-client#17
Closed

Sendgrid client doesn't close TCP connection properly #165

bidhanadh opened this issue Oct 25, 2016 · 1 comment · Fixed by sendgrid/java-http-client#17
Labels
status: help wanted requesting help from the community type: bug bug in the library

Comments

@bidhanadh
Copy link

Issue Summary

It is found that on most cases sendgrid-java client opens new connection to server but the http-connection close doesn't seem working properly which yields to TCP CLOSE_WAIT state living forever in program lifecycle. This accumulates many CLOSE_WAIT states on sending multiple emails.

Technical details:

  • sendgrid-java Version: sendgrid-java version:3.1.0 [From maven-repo]
  • Java Version: 1.8
  • OS : Mac OS X

http log

Connection request: [route: {s}->https://api.sendgrid.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
Connection leased: [id: 0][route: {s}->https://api.sendgrid.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
Opening connection {s}->https://api.sendgrid.com:443
Connecting to api.sendgrid.com/119.81.43.4:443
Connecting socket to api.sendgrid.com/119.81.43.4:443 with timeout 0
Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Starting handshake
Secure session established
negotiated protocol: TLSv1.2
negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
peer principal: CN=.api.sendgrid.com, OU=Domain Control Validated
peer alternative names: [
.api.sendgrid.com, api.sendgrid.com]
issuer principal: CN=Go Daddy Secure Certificate Authority - G2, OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
Connection established 192.168.55.189:56893<->119.81.43.4:443
Executing request POST /v3/mail/send HTTP/1.1
Proxy auth state: UNCHALLENGED
http-outgoing-0 >> POST /v3/mail/send HTTP/1.1
http-outgoing-0 >> Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
http-outgoing-0 >> Accept: application/json
http-outgoing-0 >> User-agent: sendgrid/3.0.0;java
http-outgoing-0 >> Content-Type: application/json
http-outgoing-0 >> Content-Length: 237
http-outgoing-0 >> Host: api.sendgrid.com
http-outgoing-0 >> Connection: Keep-Alive
http-outgoing-0 >> Accept-Encoding: gzip,deflate
http-outgoing-0 >> "POST /v3/mail/send HTTP/1.1[\r][\n]"
http-outgoing-0 >> "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
http-outgoing-0 >> "Accept: application/json[\r][\n]"
http-outgoing-0 >> "User-agent: sendgrid/3.0.0;java[\r][\n]"
http-outgoing-0 >> "Content-Type: application/json[\r][\n]"
http-outgoing-0 >> "Content-Length: 237[\r][\n]"
http-outgoing-0 >> "Host: api.sendgrid.com[\r][\n]"
http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
http-outgoing-0 >> "[\r][\n]"
http-outgoing-0 >> "{"from":{"name":"xxxxxxx","email":"xxxxxxxxxxxxxx"},"personalizations":[{"to":[{"email":"xxxxxxxxxxxxxx"}],"substitutions":{"xxxxxxxxxxxxxx":"xxxxxxxxxxxxxx"}}],"template_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx"}"
http-outgoing-0 << "HTTP/1.1 202 Accepted[\r][\n]"
http-outgoing-0 << "Server: nginx[\r][\n]"
http-outgoing-0 << "Date: Tue, 25 Oct 2016 00:20:35 GMT[\r][\n]"
http-outgoing-0 << "Content-Type: text/plain; charset=utf-8[\r][\n]"
http-outgoing-0 << "Content-Length: 0[\r][\n]"
http-outgoing-0 << "Connection: keep-alive[\r][\n]"
http-outgoing-0 << "X-Message-Id: EQd0l8CwSxixyIZepqG3QA[\r][\n]"
http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
http-outgoing-0 << "[\r][\n]"
http-outgoing-0 << HTTP/1.1 202 Accepted
http-outgoing-0 << Server: nginx
http-outgoing-0 << Date: Tue, 25 Oct 2016 00:20:35 GMT
http-outgoing-0 << Content-Type: text/plain; charset=utf-8
http-outgoing-0 << Content-Length: 0
http-outgoing-0 << Connection: keep-alive
http-outgoing-0 << X-Message-Id: EQd0l8CwSxixyIZepqG3QA
http-outgoing-0 << X-Frame-Options: DENY
Connection can be kept alive indefinitely
Connection [id: 0][route: {s}->https://api.sendgrid.com:443] can be kept alive indefinitely
Connection released: [id: 0][route: {s}->https://api.sendgrid.com:443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]

TCP State

java 1654 xxxxxxxxx 178u IPv6 0x80cc5c0cfdc500ad 0t0 TCP 192.168.55.189:53928->42.70.5177.ip4.static.sl-reverse.com:https (CLOSE_WAIT)
java 1654 xxxxxxxxx 180u IPv6 0x80cc5c0cfdc4fb4d 0t0 TCP 192.168.56.1:53927->vm:postgresql (ESTABLISHED)
java 1654 xxxxxxxxx 181u IPv6 0x80cc5c0cfdc510cd 0t0 TCP 192.168.55.189:54111->4.2b.5177.ip4.static.sl-reverse.com:https (CLOSE_WAIT)

@bidhanadh bidhanadh changed the title Sendgrid client does'n close TCP connection properly Sendgrid client does'nt close TCP connection properly Oct 25, 2016
@bidhanadh bidhanadh changed the title Sendgrid client does'nt close TCP connection properly Sendgrid client doesn't close TCP connection properly Oct 25, 2016
@thinkingserious thinkingserious added type: bug bug in the library status: help wanted requesting help from the community hacktoberfest labels Oct 25, 2016
@thinkingserious
Copy link
Contributor

Thanks @bidhanadh!

I've added this to our backlog for a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants