Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1786

Client-side termination of the connection is not handled properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2.13.Final, 2.0.42.Final
    • 2.1.3.Final
    • None
    • None
    • Hide

      Reproduction Steps:

      1. Clone https://github.com/xmcax/sse-demo
      2. Run via './gradlew :run'
      3. Go to http://localhost:8080/web
      4. Close the web agent while the connection is opened

       

      Actual:

      The container waits until the connection times-out. AsyncListener.onError does not get called.

      2020-09-15 10:39:19.064 INFO 225373 --- [ XNIO-1 task-2] : Worker started
      2020-09-15 10:39:19.067 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:20.067 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:21.067 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:22.066 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:23.066 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:24.066 INFO 225373 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:39:24.075 ERROR 225373 --- [pool-1-thread-1] : Writing failed
      2020-09-15 10:39:29.071 INFO 225373 --- [ XNIO-1 task-1] : Async timeout
      2020-09-15 10:39:29.075 INFO 225373 --- [ XNIO-1 task-3] : Async completed
      2020-09-15 10:39:29.075 INFO 225373 --- [ XNIO-1 task-2] : Worker completed - exiting
      

      Notice that the worker completes in 10 seconds, which is the timeout set on asyncContext

      Expected:

      The container should immediately close the connection and/ or trigger AsyncListener.onError.
      For instance Tomcat 9.0.37 produces the following log:

      2020-09-15 10:47:09.931  INFO 226850 --- [nio-8080-exec-3] : Worker started
      2020-09-15 10:47:09.935  INFO 226850 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:47:10.933  INFO 226850 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:47:11.933  INFO 226850 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:47:12.933  INFO 226850 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:47:13.933  INFO 226850 --- [pool-1-thread-1] : Job writing
      2020-09-15 10:47:13.934 ERROR 226850 --- [pool-1-thread-1] : Writing failed
      2020-09-15 10:47:13.934  INFO 226850 --- [nio-8080-exec-4] : Async error
      2020-09-15 10:47:13.992  INFO 226850 --- [nio-8080-exec-4] : Async completed
      2020-09-15 10:47:13.992  INFO 226850 --- [nio-8080-exec-3] : Worker completed - exiting
      

      Notice that the Runnable completes immediately upon failure.

      Show
      Reproduction Steps: Clone https://github.com/xmcax/sse-demo Run via './gradlew :run' Go to http://localhost:8080/web Close the web agent while the connection is opened   Actual: The container waits until the connection times-out. AsyncListener.onError does not get called. 2020-09-15 10:39:19.064 INFO 225373 --- [ XNIO-1 task-2] : Worker started 2020-09-15 10:39:19.067 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:20.067 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:21.067 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:22.066 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:23.066 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:24.066 INFO 225373 --- [pool-1-thread-1] : Job writing 2020-09-15 10:39:24.075 ERROR 225373 --- [pool-1-thread-1] : Writing failed 2020-09-15 10:39:29.071 INFO 225373 --- [ XNIO-1 task-1] : Async timeout 2020-09-15 10:39:29.075 INFO 225373 --- [ XNIO-1 task-3] : Async completed 2020-09-15 10:39:29.075 INFO 225373 --- [ XNIO-1 task-2] : Worker completed - exiting Notice that the worker completes in 10 seconds, which is the timeout set on asyncContext Expected: The container should immediately close the connection and/ or trigger AsyncListener.onError. For instance Tomcat 9.0.37 produces the following log: 2020-09-15 10:47:09.931 INFO 226850 --- [nio-8080-exec-3] : Worker started 2020-09-15 10:47:09.935 INFO 226850 --- [pool-1-thread-1] : Job writing 2020-09-15 10:47:10.933 INFO 226850 --- [pool-1-thread-1] : Job writing 2020-09-15 10:47:11.933 INFO 226850 --- [pool-1-thread-1] : Job writing 2020-09-15 10:47:12.933 INFO 226850 --- [pool-1-thread-1] : Job writing 2020-09-15 10:47:13.933 INFO 226850 --- [pool-1-thread-1] : Job writing 2020-09-15 10:47:13.934 ERROR 226850 --- [pool-1-thread-1] : Writing failed 2020-09-15 10:47:13.934 INFO 226850 --- [nio-8080-exec-4] : Async error 2020-09-15 10:47:13.992 INFO 226850 --- [nio-8080-exec-4] : Async completed 2020-09-15 10:47:13.992 INFO 226850 --- [nio-8080-exec-3] : Worker completed - exiting Notice that the Runnable completes immediately upon failure.
    • Undefined

    Description

      Undertow does not handle client-side termination of the connection opened in the asynchronous mode. Instead, it waits until the connection times-out on the server side. AsyncListener.onError does not get called.

      This has further implications when working with SseEmitters from Spring Framework  +  Undertow.

      Attachments

        Activity

          People

            rhn-cservice-bbaranow Bartosz Baranowski
            adamjnowicki Adam Nowicki (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: