Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15790

WebClient.post() not sending complete Flux on Windows

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0 RC2
    • Fix Version/s: 5.0 RC4
    • Component/s: Reactive
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Hi,
      I have a very strange issue regarding the WebClient. It seems like, that the last bit of my Flux is not sent to the server.

      I a very simple spring boot application. (just spring-boot-starter-webflux, generated by the Initializr )

      My Server Code:

      @RestController
      public class TcpStreaming {
          @PostMapping(value = "eventSink", consumes = MediaType.APPLICATION_JSON_VALUE)
          public Mono<ResponseEntity<String>> eventSink(@RequestBody Flux<SendEvent> flux) {
              return flux.doOnNext(event -> System.err.println(event.getContent()))
                      .then(Mono.just(new ResponseEntity<>(HttpStatus.OK)));
          }
      }
      

      A very simple Event Class:

      public class SendEvent {
          private String content;
      
          public SendEvent() {
          }
          public SendEvent(String content) {
              this.content = content;
          }
      }
      

      And a very simple client:

           public static void main(String[] args) {
              int toBeSent = 257;
              Flux<String> flux = Flux.range(1, toBeSent).map(count -> "{\"content\":" + "\"" + count + "\"}");
      
              WebClient client = WebClient.create();
              ClientResponse result = client.post().uri(URI.create("http://localhost:8080/eventSink"))
                      .contentType(MediaType.APPLICATION_JSON).body(flux, String.class).exchange().block();
              System.err.println(result.statusCode());
          }
      

      When i send 256 Events, every Event reaches the server and I get a HTTP 200 response. When I send 257 Events, the WebClient never returns and the Server prints out all the Events til 256 (so one is missing).When I send 10000 events, 9984 Events reaching the server.
      Either I'm using the API wrong or the last chunk of the Event Flux is not read correctly. Since 256 is the inital buffer for a lot of operators, it might be the later.

      Thanks for the help,
      Malte

        Attachments

          Activity

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              maltefinnern Malte Finnern
              Last updater:
              Rossen Stoyanchev
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                40 weeks, 5 days ago