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

scalatra-atmosphere and RichRequest conflicts getReader/getInputStream and RichRequest.cachedBody problem #722

Open
kounoike opened this issue Oct 23, 2017 · 1 comment

Comments

@kounoike
Copy link

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.

@takezoe
Copy link
Member

takezoe commented Nov 8, 2017

@kounoike Is your application communicating via WebSocket? I think this workaround looks to work for only when communication is fallbacked to Ajax polling.

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

No branches or pull requests

2 participants