Title: Intermittent "Connection reset by peer" when reusing idle OkHttp connection with Microsoft Graph Java SDK behind HTTP proxy · Issue #2654 · microsoftgraph/msgraph-sdk-java · GitHub
Open Graph Title: Intermittent "Connection reset by peer" when reusing idle OkHttp connection with Microsoft Graph Java SDK behind HTTP proxy · Issue #2654 · microsoftgraph/msgraph-sdk-java
X Title: Intermittent "Connection reset by peer" when reusing idle OkHttp connection with Microsoft Graph Java SDK behind HTTP proxy · Issue #2654 · microsoftgraph/msgraph-sdk-java
Description: Describe the bug Hi Team, We are facing an intermittent issue when using Microsoft Graph Java SDK behind a corporate HTTP proxy. Environment: Java 17 Spring Boot Microsoft Graph SDK 6.56.0 Azure Identity 1.16.0 Azure Core HTTP OkHttp 1.1...
Open Graph Description: Describe the bug Hi Team, We are facing an intermittent issue when using Microsoft Graph Java SDK behind a corporate HTTP proxy. Environment: Java 17 Spring Boot Microsoft Graph SDK 6.56.0 Azure Id...
X Description: Describe the bug Hi Team, We are facing an intermittent issue when using Microsoft Graph Java SDK behind a corporate HTTP proxy. Environment: Java 17 Spring Boot Microsoft Graph SDK 6.56.0 Azure Id...
Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-java/issues/2654
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Intermittent \"Connection reset by peer\" when reusing idle OkHttp connection with Microsoft Graph Java SDK behind HTTP proxy","articleBody":"### Describe the bug\n\nHi Team,\n\nWe are facing an intermittent issue when using Microsoft Graph Java SDK behind a corporate HTTP proxy.\n\nEnvironment:\n\nJava 17\nSpring Boot\nMicrosoft Graph SDK 6.56.0\nAzure Identity 1.16.0\nAzure Core HTTP OkHttp 1.11.12\nOkHttp Client\nCorporate HTTP Proxy\nScheduler running every 5 minutes\n\nIssue Pattern:\n\nApplication Startup:\n\nNew TCP connection created\nTLS handshake successful\nGraph API call successful\n\nSecond Scheduler Run (5 minutes later):\n\nExisting connection is reused\nNo new TCP connection created\nTLS handshake attempted\nConnection reset by peer\nRequest fails\n\nThird Scheduler Run:\n\nNew TCP connection created\nTLS handshake successful\nGraph API call successful\n\nThe Graph API being called is MailFolders.\n\nAuthentication is successful and token acquisition does not fail.\n\nAzure Identity logs show:\n\nClientSecretCredential => getToken() SUCCESS\n\nThe failure occurs during the Graph API request after token acquisition.\n\nException:\n\njava.net.SocketException: Connection reset by peer\n\nWireshark Analysis:\n\nSuccessful Request:\n\nNew TCP connection\nTLS handshake\nGraph request succeeds\n\nFailed Request:\n\nExisting connection reused\nNo new TCP connection created\nTLS handshake attempted\nConnection reset by peer\n\nNext Request:\n\nNew TCP connection created\nTLS handshake successful\nRequest succeeds\n\nAdditional Observation:\n\nWhen retryOnConnectionFailure(true) is enabled, OkHttp closes the failed connection, creates a new connection and the retry succeeds.\n\nQuestions:\n\nIs GraphServiceClient expected to reuse idle pooled OkHttp connections after several minutes?\nIs there a recommended ConnectionPool configuration for long-running scheduled workloads?\nIs there any recommended configuration for Graph SDK when using an HTTP proxy?\nHas this behavior been observed previously with Graph SDK 6.56.0?\n\nThis application previously worked with the same code and configuration and the issue started only recently without any application code changes.\n\n### Expected behavior\n\nThe Graph API request should succeed on every scheduler execution.\n\nWhen an idle connection becomes invalid, Graph SDK / OkHttp should either:\n\nCreate a new connection automatically, or\nRetry using a new connection without failing the request.\n\nWe expect consistent behavior across all scheduler executions without intermittent \"Connection reset by peer\" errors.\n\n### How to reproduce\n\n1. Create a Spring Boot application using Microsoft Graph Java SDK 6.56.0, Azure Identity 1.16.0 and azure-core-http-okhttp 1.11.12.\n2. Configure GraphServiceClient with OkHttpClient and an HTTP proxy.\n3. Create a scheduler that runs every 5 minutes.\n4. Call Microsoft Graph MailFolders API during every scheduler execution.\n5. Start the application.\n6. Observe that the first execution succeeds.\n7. Wait for the second scheduler execution.\n8. The second execution intermittently fails with:\n\njava.net.SocketException: Connection reset by peer\n\n1. Wait for the next scheduler execution.\n2. The third execution succeeds again.\n\nWireshark observations:\n\n- First execution creates a new TCP connection and succeeds.\n- Second execution reuses an existing connection and fails with connection reset.\n- Third execution creates a new TCP connection and succeeds.\n\nThe issue is reproducible only when connection reuse occurs after an idle period.\n\n### SDK Version\n\n6.56.0\n\n### Latest version known to work for scenario above?\n\nUnknown. The same application and configuration previously worked successfully. The issue started recently without application code \n\n### Known Workarounds\n\nWe found that enabling retryOnConnectionFailure(true) reduces the occurrence of the issue. When the connection reset occurs, OkHttp closes the failed connection, creates a new connection and retries the request successfully.\nWe are also testing ConnectionPool configuration with a shorter idle timeout to prevent reuse of older idle connections.\nAdditionally, the next scheduler execution usually succeeds because a completely new TCP connection is created.\nThe root cause is still under investigation.\n\n### Debug output\n\n[connection-reset-log-summary.txt](https://github.com/user-attachments/files/30889380/connection-reset-log-summary.txt)\n\nApplication startup:\n\nNew TCP connection created\nTLS handshake completed successfully\nGraph MailFolders API call successful\n\nSecond scheduler execution (approximately 5 minutes later):\n\nExisting connection reused\nNo new TCP connection created\nTLS handshake attempted\nConnection reset by peer\nRequest failed\n\nThird scheduler execution:\n\nNew TCP connection created\nTLS handshake completed successfully\nGraph MailFolders API call successful\n\nAuthentication behavior:\n\nToken acquisition succeeds successfully\nClientSecretCredential getToken returns SUCCESS\nFailure occurs after token acquisition during Graph API execution\n\nObserved exception:\n\njava.net.SocketException: Connection reset by peer\n\nRelevant stack trace location:\n\nHttp1ExchangeCodec.readResponseHeaders\nExchange.readResponseHeaders\nMailFoldersRequestBuilder.get\n\nWireshark observations:\n\nSuccessful execution:\n\nNew TCP connection\nTLS handshake successful\nRequest successful\n\nFailed execution:\n\nExisting connection reused\nNo new TCP connection created\nTLS handshake attempted\nConnection reset by peer\n\nNext execution:\n\nNew TCP connection created\nTLS handshake successful\nRequest successful\n\nAdditional observation:\n\nWhen retryOnConnectionFailure(true) is enabled, the request succeeds because OkHttp creates a new connection and retries automatically.\n\n### Configuration\n\n[GraphServiceClient_Config.txt](https://github.com/user-attachments/files/30889393/GraphServiceClient_Config.txt)\n\nOS:\nAKS (Azure Kubernetes Service) running Linux based containers in production\nMicrosoft Graph Java SDK application deployed as a containerized microservice\nLocal testing performed on Windows Server\n\nIs it specific to this configuration?\nCurrently investigating.\nIssue observed in AKS hosted microservice environment.\nCorporate HTTP proxy is used in both environments.\n\n### Other information\n\nWe believe the issue may be related to connection reuse after an idle period.\n\nObservations:\n\nScheduler runs every 5 minutes.\nFirst Graph API call after application startup always succeeds.\nSecond scheduler execution intermittently fails with \"Connection reset by peer\".\nThird scheduler execution succeeds again.\n\nBased on Wireshark analysis:\n\nSuccessful execution creates a new TCP connection and performs a successful TLS handshake.\nFailed execution attempts to reuse an existing connection.\nNo new TCP connection is established during the failed execution.\nTLS handshake is attempted and the connection is reset.\nThe next successful execution creates a new TCP connection and succeeds.\n\nAdditional observations:\n\nAuthentication is successful.\nAzure Identity token acquisition succeeds.\nFailure occurs during Graph API execution and not during token acquisition.\n\nWorkaround identified:\n\nEnabling retryOnConnectionFailure(true) reduces the issue because OkHttp creates a new connection and retries successfully.\nReducing connection pool idle timeout also appears to reduce the occurrence.\n\nQuestions:\n\nIs this expected behavior when GraphServiceClient is used with OkHttp and a corporate HTTP proxy?\nIs there a recommended connection pool or retry configuration for long-running scheduler workloads?\nIs there any known issue involving reuse of idle connections in this scenario?\n\n[GraphServiceClient_Config.txt](https://github.com/user-attachments/files/30889254/GraphServiceClient_Config.txt)","author":{"url":"https://github.com/AbdulAlSowdhS","@type":"Person","name":"AbdulAlSowdhS"},"datePublished":"2026-08-10T07:19:39Z","url":"https://github.com/microsoftgraph/msgraph-sdk-java/issues/2654"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dd51f4ad-2ac5-2c9e-c16b-0c05532740d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B74:2BCB50:A1077:DEEBF:6AF6BAD9 |
| html-safe-nonce | 6f25026d14a6ea843daef6a8b05b9df89dae3acb8cf63763e2366db95775f63c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Qjc0OjJCQ0I1MDpBMTA3NzpERUVCRjo2QUY2QkFEOSIsInZpc2l0b3JfaWQiOiIxMjkxMzIxMDUwNzgzOTg4NDQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 66b183e0ea0018de34b32f2a287fa7b5af989a38d7937b49b05957c5d17b3414 |
| hovercard-subject-tag | issue:5107648240 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-java/2654/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96ef84f9e5744c35c8d961274540e2bd38de4cfb1409e096fe3cb63d262eadd9/microsoftgraph/msgraph-sdk-java/issues/2654 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96ef84f9e5744c35c8d961274540e2bd38de4cfb1409e096fe3cb63d262eadd9/microsoftgraph/msgraph-sdk-java/issues/2654 |
| og:image:alt | Describe the bug Hi Team, We are facing an intermittent issue when using Microsoft Graph Java SDK behind a corporate HTTP proxy. Environment: Java 17 Spring Boot Microsoft Graph SDK 6.56.0 Azure Id... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AbdulAlSowdhS |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8dfae1499400ee498ab0f86538d1c034e6c1b4f51c63ecade775c3b0894e3379 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoftgraph/msgraph-sdk-java git https://github.com/microsoftgraph/msgraph-sdk-java.git |
| octolytics-dimension-user_id | 17304259 |
| octolytics-dimension-user_login | microsoftgraph |
| octolytics-dimension-repository_id | 103300409 |
| octolytics-dimension-repository_nwo | microsoftgraph/msgraph-sdk-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 103300409 |
| octolytics-dimension-repository_network_root_nwo | microsoftgraph/msgraph-sdk-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ee168845eb2be91203b179104ac9977fe4ea69a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width