Skip to content

Intermittent Connection Reset with Spring HTTP Clients When Interacting with HTTP/1.0 Server #34228

Closed as not planned
@CHOICORE

Description

@CHOICORE

Spring HTTP Client Issues with HTTP/1.0 Server Integration

Issue Summary

Spring HTTP clients (WebClient, RestClient, RestTemplate) fail to properly receive data from the server, while the same requests work fine with HttpURLConnection, OpenFeign, and OkHttp3. Intermittent "Connection reset" exceptions occur during response reading.

Server Response Analysis (via Wireshark)

  • Server responds with HTTP/1.0
  • Response headers include "Connection: close" , "Content-Type: application/json"

Steps to Reproduce

  1. Send HTTP request using Spring's HTTP clients (WebClient or RestTemplate)
  2. Server responds with HTTP/1.0 and "Connection: close", "Content-Type: application/json"
  3. While reading the response, connection is reset intermittently

We're experiencing two distinct issues while integrating with a legacy HTTP/1.0 server that we cannot modify:

  1. Content-Length Header Problem
  2. Intermittent Connection Resets

Issue 1: Missing Content-Length Header

Problem Statement

  • Server operates on HTTP/1.0 protocol requiring mandatory Content-Length header
  • Spring HTTP clients are not including this header automatically
  • StringHttpMessageConverter works (includes Content-Length)
  • MappingJackson2HttpMessageConverter fails (missing Content-Length)
  • Results in server rejections or improper request handling

Current Behavior

  • Requests fail without Content-Length header
  • Only working with StringHttpMessageConverter
  • Other converters failing consistently
  • Direct impact on request reliability

Issue 2: Intermittent Connection Reset

Problem Statement

  • Random connection resets during response processing
  • Specific to HTTP/1.0 responses with "Connection: close" header
  • Only occurs with Spring HTTP clients
  • Alternative clients work fine (HttpURLConnection, OpenFeign, OkHttp3)

Current Behavior

  • Unpredictable connection drops
  • Data loss during response reading
  • Failed requests requiring retry
  • Inconsistent response handling

Environment

  • Spring Framework: 6.2.1
  • Java: 21
  • Third-party Server Protocol: HTTP/1.0
  • Response Headers: Connection: close, Content-Type: application/json

Questions

  1. Is there a recommended configuration for handling HTTP/1.0 servers with mandatory Content-Length?
  2. How can we properly handle the "Connection: close" behavior in Spring HTTP clients?
  3. Are there known workarounds for these issues in Spring Framework?
  4. Would using alternative message converters or custom implementations help?

Additional Information

  • Server configuration cannot be modified

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions