Fork me on GitHub
#pedestal
<
2020-11-17
>
Mehdi H.11:11:40

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.13:11:56

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 "[email protected]"], :throwable #error {
 :cause "Close [email protected][PROCESSING][i=null,[email protected]] in state PROCESSING"
 :via
 [{:type java.io.IOException
   :message "Close [email protected][PROCESSING][i=null,[email protected]] 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.14:11:49

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.