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

Handle :undefined port #729

Merged
merged 1 commit into from
Jul 5, 2018
Merged

Handle :undefined port #729

merged 1 commit into from
Jul 5, 2018

Conversation

webengineer-max
Copy link
Contributor

I am getting an error

Failure while translating Erlang's logger event ** (ArgumentError) argument error :erlang.integer_to_binary(:undefined) (plug) lib/plug/adapters/translator.ex:91: Plug.Adapters.Translator.server_info/1 (plug) lib/plug/adapters/translator.ex:87: Plug.Adapters.Translator.conn_info/2 (plug) lib/plug/adapters/translator.ex:59: Plug.Adapters.Translator.translate_ranch/5 (logger) lib/logger/erlang_handler.ex:104: Logger.ErlangHandler.translate/6 (logger) lib/logger/erlang_handler.ex:97: Logger.ErlangHandler.translate/5 (logger) lib/logger/erlang_handler.ex:30: anonymous fn/3 in Logger.ErlangHandler.log/2 (logger) lib/logger.ex:764: Logger.normalize_message/2

while opening address without a port, e.g. https://example.com. But it's properly formatted with non-default port, e.g. https://example.com:4040

#PID<0.777.0> running Pult.Router (connection #PID<0.776.0>, stream id 1) terminated Server: localhost:443 (https) Request: GET / ** (exit) an exception was raised: ** (Plug.Conn.AlreadySentError) the response was already sent (plug) lib/plug/conn.ex:544: Plug.Conn.resp/3 (plug) lib/plug/conn.ex:531: Plug.Conn.send_resp/3 (pult) lib/pult/router.ex:1: Pult.Router.plug_builder_call/2 (plug) lib/plug/adapters/cowboy2/handler.ex:12: Plug.Adapters.Cowboy2.Handler.init/2 (cowboy) /home/profi/Code/sv/deps/rpi3/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2 (cowboy) /home/profi/Code/sv/deps/rpi3/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.execute/3 (cowboy) /home/profi/Code/sv/deps/rpi3/cowboy/src/cowboy_stream_h.erl:252: :cowboy_stream_h.request_process/3 (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

I believe the issue is with Plug.Conn having port :undefined that's not processed here in translator.ex:91 like at

{:undefined, {_, port}} -> %{port: port}
.

I am using https://hex.pm/packages/logger_papertrail_backend (however not sure if it has any influence on the issue).

@josevalim josevalim merged commit abe9eae into elixir-plug:master Jul 5, 2018
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

Gazler pushed a commit to Gazler/plug that referenced this pull request Oct 18, 2018
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

Successfully merging this pull request may close these issues.

2 participants