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

How to return Protobuff binary from server ? #180

Open
vsaji opened this issue Oct 26, 2018 · 1 comment
Open

How to return Protobuff binary from server ? #180

vsaji opened this issue Oct 26, 2018 · 1 comment

Comments

@vsaji
Copy link

vsaji commented Oct 26, 2018

We are evaluating rapidoid for one of our projects. While trying with Protobuff stream, we were able to send the stream to server, however, we have no clue how to return a binary data to the client.

We could read the data via Req.body().
We have tried with Req and ReqResHandler, but they both return object but we don't know what to return.

We tried returning instance of Resp (req.response() from Req or Resp from ReqResHandler) after setting the outputstrem (Resp.out). But it threw the following exception. Kindly help.

ERROR | 26/Oct/2018 12:36:39:319 | executor1 | org.rapidoid.net.impl.RapidoidConnection | Tried to resume a job that already has finished! | handle = 1 | currentHandle = 1 | job = org.rapidoid.http.impl.RespImpl$1@50e2dba6
ERROR | 26/Oct/2018 12:36:39:320 | executor1 | org.rapidoid.http.impl.lowlevel.LowLevelHttpIO | Error occurred when handling request! | error = java.lang.RuntimeException: Tried to resume a job that already has finished!
java.lang.RuntimeException: Tried to resume a job that already has finished!
       at org.rapidoid.u.U.rte(U.java:423)
       at org.rapidoid.net.impl.RapidoidConnection.resume(RapidoidConnection.java:372)
       at org.rapidoid.http.impl.RespImpl.resume(RespImpl.java:422)
       at org.rapidoid.http.impl.RespImpl.chunk(RespImpl.java:531)
       at org.rapidoid.http.impl.ChunkedResponse.flush(ChunkedResponse.java:70)
       at org.rapidoid.http.impl.ChunkedResponse.close(ChunkedResponse.java:77)
       at org.rapidoid.io.IO.close(IO.java:291)
       at org.rapidoid.http.impl.RespImpl.finish(RespImpl.java:561)
       at org.rapidoid.http.impl.ReqImpl.onDone(ReqImpl.java:534)
       at org.rapidoid.http.impl.ReqImpl.done(ReqImpl.java:510)
       at org.rapidoid.http.handler.HttpManagedHandlerDecorator.processNormalResult(HttpManagedHandlerDecorator.java:232)
       at org.rapidoid.http.handler.HttpManagedHandlerDecorator.complete(HttpManagedHandlerDecorator.java:223)
       at org.rapidoid.http.handler.HttpManagedHandlerDecorator.handleWithWrappers(HttpManagedHandlerDecorator.java:109)
       at org.rapidoid.http.handler.HttpManagedHandlerDecorator.access$200(HttpManagedHandlerDecorator.java:39)
       at org.rapidoid.http.handler.HttpManagedHandlerDecorator$2.run(HttpManagedHandlerDecorator.java:83)
       at org.rapidoid.job.PredefinedContextJobWrapper.run(PredefinedContextJobWrapper.java:56)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:745)
@judepereira
Copy link

It appears that one needs to return the response object, as documented here: https://www.rapidoid.org/docs.html#_sending_chunked_http_response

Doing so solved it for me.

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