2

如何修复 Akka HTTP 中增加最大方法长度的问题。我在 Web 套接字连接服务中遇到以下问题。

Illegal request, responding with status '400 Bad Request': Unsupported
 HTTP method: HTTP method too long (started with 'メ﾿vN'). Increase 
`akka.http.server.parsing.max-method-length` to support HTTP methods with more characters.

我在application.conf添加了akka.http.server.parsing.max-method-length。添加max-method-length后,我也遇到了同样的问题,我的 .conf 文件是:

    app {
  interface = "0.0.0.0"
  port = 7000
}

# Cors allowed origin configuration
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cors {
 allowed-origin = "http://127.0.0.1"
}


akka {
  http {
    server.parsing.illegal-header-warnings = off
    client.parsing.illegal-header-warnings = off
  }
}
akka.http.server.parsing.max-method-length =500
4

3 回答 3

4

我遇到了同样的错误,也没有成功更改 max-method-length conf 值。

我的问题是我的请求 URL 错误地使用了 https 而不是 http。将我的请求更改为 http:// 后,上述错误停止发生

于 2018-09-17T18:43:12.797 回答
0

当故意在 HTTPS 端口上以开发模式运行应用程序时,我遇到了同样的问题sbt "run -Dhttps.port=9443 -Dhttp.port=disabled"

./conf/generated.keystore结果证明,Play 试图在( )中为自称证书生成密钥,INFO play.core.server.ssl.FakeKeyStore "Generating HTTPS key pair in %appdir%/conf/generated.keystore但由于没有./conf文件夹而默默地失败了。

解决方案:创建conf文件夹以便 Play 可以创建generated.keystore文件,或提供正确的路径play.server.https.keyStore.path。在此处查看更多信息:https ://www.playframework.com/documentation/2.7.x/ConfiguringHttps

于 2019-04-25T14:09:27.443 回答
-1

当我使用错误的端口访问 https 时,我遇到了同样的错误。

例如我玩了运行http://localhost:9000

当我在 9443 上启用 https 端口时

我访问https://localhost:9000会得到同样的错误信息。

更改为https://localhost:9443将解决此问题。

于 2019-02-27T06:33:16.800 回答