Elixir.Plug.TimeoutError caused by Plug.Parsers.URLENCODED.parse when POSTing Phoenix forms

I am seeing an Elixir.Plug.TimeoutError when our users try to POST a Phoenix form. This issue is intermittent and only occurs for a small portion of our users.

I am not sure whether this is caused by either (1) Plug.Conn.read_body being called twice somehow, or (2) the request timing out because of the user’s computer.

The docs for Plug.Conn.read_body mention that the parser can be reconfigured to handle slower clients (Plug.Conn — Plug v1.15.2)

In order to, for instance, support slower clients you can tune the :read_length and :read_timeout options. These specify how much time should be allowed to pass for each read from the underlying socket.

Does the same apply for Plug.Parsers.URLENCODED?
https://hexdocs.pm/plug/Plug.Parsers.URLENCODED.html

I have tried reconfiguring Plug.Parsers, but it does not seem to have helped:

  parsers: [:urlencoded, :multipart, :json],
  pass: ["*/*"],
  json_decoder: Poison,
  length: 8_000_000_000,
  read_timeout: 45_000,
  read_length: 3_000_000

Thanks

1 Like