pedestal

Mehdi H. 2020-11-17T11:45:40.164500Z

Hi all! I am trying out SSE with Pedestal + Jetty. My stream-ready function is really basic and adds an event every second to the channel (with a buffer of 200). For some reason, it takes around a minute to start the stream to the client (cljs + fetch), it bursts around 60 messages and it then ends the stream. Have anyone experienced that? Is it something that could be linked to some Jetty buffering and queue flushing? Thanks in advance!

Mehdi H. 2020-11-17T13:27:56.165Z

This is the error I am getting:

ERROR io.pedestal.http.impl.servlet-interceptor [async-dispatch-3]
{:msg "An error occured when async writing to the client", :line 116, :src-chan #object[clojure.core.async.impl.channels.ManyToManyChannel 0x1ce67b "clojure.core.async.impl.channels.ManyToManyChannel@1ce67b"], :throwable #error {
 :cause "Close org.eclipse.jetty.server.HttpConnection$SendCallback@55b587d4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@15b51ddb] in state PROCESSING"
 :via
 [{:type java.io.IOException
   :message "Close org.eclipse.jetty.server.HttpConnection$SendCallback@55b587d4[PROCESSING][i=null,cb=org.eclipse.jetty.server.HttpChannel$SendCallback@15b51ddb] in state PROCESSING"
   :at [org.eclipse.jetty.util.IteratingCallback close "IteratingCallback.java" 427]}]
 :trace
 [[org.eclipse.jetty.util.IteratingCallback close "IteratingCallback.java" 427]
  [org.eclipse.jetty.server.HttpConnection onClose "HttpConnection.java" 519]
  [org.eclipse.jetty.io.ssl.SslConnection onClose "SslConnection.java" 289]
  [org.eclipse.jetty.io.SelectorManager connectionClosed "SelectorManager.java" 345]
  [org.eclipse.jetty.io.ManagedSelector$DestroyEndPoint run "ManagedSelector.java" 956]
  [org.eclipse.jetty.util.thread.QueuedThreadPool runJob "QueuedThreadPool.java" 698]
  [org.eclipse.jetty.util.thread.QueuedThreadPool$Runner run "QueuedThreadPool.java" 804]
  [java.lang.Thread run "Thread.java" 748]]}}

Mehdi H. 2020-11-17T14:11:49.167Z

With an event put every 10 seconds in the channel, the error still comes around but the connexion isn't shut down. So maybe the error message isn't linked to the connexion being closed despite the message? And maybe this is a client side issue where the client cannot deal with a one event per second load? Even if this is the case, the 60sec start time for the sse stream to start outputting events is puzzling.