Play framework websevice - activator start issue w

2019-08-10 05:58发布

问题:

I am creating web-service APIs using the Play framework with Java. I have created the service successfully.

WHAT I DID:

In one web service request, I have sent the base64 string. If I passed the base64 string in the request, I got the below exception.

[warn] p.nettyException - Handling TooLongFrameException
org.jboss.netty.handler.codec.frame.TooLongFrameException: An HTTP line is larger than 4096 bytes.

After searching in the internet, I got the below solution.

export SBT_OPTS="-Xms1024m -Xmx3084m -XX:MaxPermSize=1024m -Dhttp.netty.maxInitialLineLength=8192"

After setting the SBT_OPTS, I can pass the base64 string in the request and receive it on the server side successfully.

I used the following command for debugging purpose - "activator -jvm-debug 9999 run". So it is working fine.

WHAT IS ISSUE:

But now I tried to deploy this as service. So that I used the following commands - "activator start" (or) "activator start $SBT_OPTS" (or) "activator $SBT_OPTS start".

When I use this commands to start the service, I got the same above issue - "An HTTP line is larger than 4096 bytes."

Can anyone help me to fix this issue?

回答1:

Please add the below line in your application.conf, then you don't need to set any config at runtime

parsers.text.maxLength=7024K

Its accept the request data upto 7MB, if you need more, you can set it. https://www.playframework.com/documentation/2.3.x/JavaBodyParsers