Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABORTED triggered by repeated video elements with ring-jetty9-adapter <= 0.17.8 #133

Open
deas opened this issue Apr 16, 2024 · 2 comments

Comments

@deas
Copy link

deas commented Apr 16, 2024

The following code triggers java.lang.IllegalStateException: ABORTED with ring-jetty9-adapter <= 0.17.8 for me accessing the page at http://localhost:3000. It hit me while I was playing with biff (/cc @jacobobryant).

It appears to be related to the file size of the video - I do not see it with small files.

I also cannot reproduce it using

ab -n 100 -c 10 http://localhost:3000/bunny.mp4

and it does not happen with ring-jetty9-adapter 0.32.4.

$ clojure -M -m abort-jetty
...
[qtp1405548909-39] WARN org.eclipse.jetty.server.HttpChannel - /bunny.mp4
java.lang.IllegalStateException: ABORTED
        at org.eclipse.jetty.server.HttpChannelState.sendError(HttpChannelState.java:911)
        at org.eclipse.jetty.server.Response.sendError(Response.java:492)
        at ring.adapter.jetty9$proxy_handler$fn__866.invoke(jetty9.clj:82)
        at ring.adapter.jetty9.proxy$org.eclipse.jetty.servlet.ServletHandler$ff19274a.doHandle(Unknown Source)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1378)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
        at ring.adapter.jetty9.proxy$org.eclipse.jetty.servlet.ServletHandler$ff19274a.doScope(Unknown Source)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1300)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
        at org.eclipse.jetty.server.Server.handle(Server.java:562)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:418)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:675)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:410)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
        at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
        at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
        at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
        at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:138)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:407)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
        at java.base/java.lang.Thread.run(Thread.java:1583)
(ns abort-jetty
  (:import [java.io File]
           [java.util UUID])
  (:require [ring.adapter.jetty9 :as jetty]
            [clojure.java.io :as io]
            [clojure.string :as str]
            [ring.middleware.file :as file]))

(def fileurl "https://docs.evostream.com/sample_content/assets/bunny.mp4")

(defn filename [] (-> fileurl (str/split #"/") last))

(defn handler [_]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body (str "<body>"
              (apply str (map #(str "<video style=\"width:100px;\" src=\"" (filename) "?" (str (UUID/randomUUID) %) "\"></video>")
                              (range 1 10)))
              "</body>")})

(defn -main [& _]
  (let [path (or (System/getenv "VIDEO_FOLDER") ".")
        fpath (str path File/separator  (filename))]
    (when (not (-> fpath io/file .exists))
      (with-open [out (io/output-stream fpath)]
        (io/copy (io/input-stream fileurl) out))))
  (jetty/run-jetty (-> handler
                       (file/wrap-file (or (System/getenv "VIDEO_FOLDER") ".")))
                   {:port 3000 :join? false}))
{:paths ["src"]
 :deps #_{org.clojure/clojure {:mvn/version "1.11.2"}
        ring/ring-core {:mvn/version "1.10.0"}
        info.sunng/ring-jetty9-adapter {:mvn/version "0.32.4"}
        org.slf4j/slf4j-simple     {:mvn/version "2.0.0-alpha5"}}
        {org.clojure/clojure {:mvn/version "1.10.3"}
         ring/ring-core {:mvn/version "1.9.6"}
         info.sunng/ring-jetty9-adapter {:mvn/version "0.17.2"}
         org.slf4j/slf4j-simple     {:mvn/version "2.0.0-alpha5"}
         }}
@sunng87
Copy link
Owner

sunng87 commented Apr 19, 2024

I think the error is not from this adapter. The line for jetty9.clj:82 is just re-throw the exception. It sounds pretty much like the client connection lost while server is streaming a large file.

@deas
Copy link
Author

deas commented Apr 19, 2024

You may be right that it is not from the adapter. The strange bit is that I can easily reproduce it locally with 0.17.x and pretty much any browser - and not with 0.32.x. I may have missed something in the browsers, but I have not seen them reporting an error. May also be in jetty?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants