I'm trying implement gitbucket-chat-plugin with scalatra-atmosphere. I made simple websocket-based chat. It works fine with sbt jetty:start, embedded Jetty. But it fails on Tomcat.
first problem
I got exception it says "already used getInputStream" when calling getReader method.
second problem
I fix readBody with getInputStream, but it returns body as empty string always on Tomcat. On Jetty, it works fine.
third problem
I tried to find method which read body with getInputStream. I found it is RichRequest.
So, I changed readBody to RichRequest(request).body. Then it works fine on Tomcat. But it doesn't works on Jetty, it repeats first message's body eternally. It seems as cachedBody doesn't clear when handled message.
workaround
I have a workaround. But I don't have any confidence.
readBody returns RichRequest(request).body
make clearCachedBody method to RichRequest.
after handled message, call clearCachedBody.
version
I'm using scalatra-2.6.0-SNAPSHOT because 2.5.x uses too old version of atmosphere library.
@kounoike Is your application communicating via WebSocket? I think this workaround looks to work for only when communication is fallbacked to Ajax polling.
I'm trying implement gitbucket-chat-plugin with scalatra-atmosphere. I made simple websocket-based chat. It works fine with sbt jetty:start, embedded Jetty. But it fails on Tomcat.
first problem
I got exception it says "already used getInputStream" when calling getReader method.
second problem
I fix readBody with getInputStream, but it returns body as empty string always on Tomcat. On Jetty, it works fine.
third problem
I tried to find method which read body with getInputStream. I found it is RichRequest. So, I changed readBody to
RichRequest(request).body
. Then it works fine on Tomcat. But it doesn't works on Jetty, it repeats first message's body eternally. It seems ascachedBody
doesn't clear when handled message.workaround
I have a workaround. But I don't have any confidence.
RichRequest(request).body
clearCachedBody
method to RichRequest.clearCachedBody
.version
I'm using scalatra-2.6.0-SNAPSHOT because 2.5.x uses too old version of atmosphere library.