Bad value on output port 'tcp_inet'

2019-07-12 19:05发布

问题:

I'm using the Phoenix framework, which is running Cowboy underneath. I am occasionally seeing the following pair of errors in my log:

Bad value on output port 'tcp_inet'

GenServer #PID<0.8423.1> terminating
** (FunctionClauseError) no function clause matching in :http_transport.close/2
(inets) http_transport.erl:346: :http_transport.close(:undefined, #Port<0.18079778>)
(stdlib) gen_server.erl:643: :gen_server.try_terminate/3
(stdlib) gen_server.erl:809: :gen_server.terminate/7
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3  

All the searching I could think of points to something sending a tuple to gen_tcp:send(). But that is way down under layers of stuff when you're writing at the level of Phoenix.

The server seems to keep rolling so I'm not panicking over this, but I'd like to get to the bottom of it to stop these errors. Anyone know what would be causing this?

回答1:

I was receiving

Bad value on output port 'tcp_inet'

In my phoenix api that I had deployed to heroku. In my case, I was setting response headers with an atom. Once I changed the atom to a binary everything started working fine again.

Most likely, this may have something to do with a Plug that is modifying your headers.