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

        Activity

        Hide
        rstoya05-aop Rossen Stoyanchev added a comment -

        Malte Finnern, since #134 is now resolved, could you give it a try?

        Show
        rstoya05-aop Rossen Stoyanchev added a comment - Malte Finnern , since #134 is now resolved, could you give it a try?
        Hide
        rstoya05-aop Rossen Stoyanchev added a comment -

        I am resolving for now since it should be fixed and in any case the fix is in Reactor Netty but feel free to comment.

        Show
        rstoya05-aop Rossen Stoyanchev added a comment - I am resolving for now since it should be fixed and in any case the fix is in Reactor Netty but feel free to comment.
        Hide
        maltefinnern Malte Finnern added a comment -

        Hey,

        I tested the current repository version on Windows. I updated everything (reactor-netty-0.7.0M1 is now the dependency). I'm afraid that it still does not work on my side. Is there any check, that I have the correct .jars?

        Regards,
        Malte

        Show
        maltefinnern Malte Finnern added a comment - Hey, I tested the current repository version on Windows. I updated everything (reactor-netty-0.7.0M1 is now the dependency). I'm afraid that it still does not work on my side. Is there any check, that I have the correct .jars? Regards, Malte
        Hide
        violetagg Violeta Georgieva added a comment -

        Hello,

        The fix for that issue will be in Reactor Netty 0.7.0.M2 which is about to be released.
        Do you think you can test with the current 0.7.0.BUILD-SNAPSHOT version?

        Thanks in advance,
        Violeta

        Show
        violetagg Violeta Georgieva added a comment - Hello, The fix for that issue will be in Reactor Netty 0.7.0.M2 which is about to be released. Do you think you can test with the current 0.7.0.BUILD-SNAPSHOT version? Thanks in advance, Violeta
        Hide
        maltefinnern Malte Finnern added a comment -

        Hi,

        it works with 0.7.0.BUILD-SNAPSHOT!

        Thanks for the fix,
        Malte

        Show
        maltefinnern Malte Finnern added a comment - Hi, it works with 0.7.0.BUILD-SNAPSHOT! Thanks for the fix, Malte

          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:
              10 weeks, 2 days ago