5

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?

Matt
  • 84,419
  • 25
  • 57
  • 67
  • Sorry - accidental downvote that I didn't catch for 30 minutes. Will upvote elsewhere to make up the rep. – Cody Poll Aug 03 '16 at 19:59
  • Matt — is this happening in development mode? I would try changing the port number in `config/dev.exs` to see if that makes a difference. – Svilen Aug 03 '16 at 21:47
  • [There is an issue on GitHub](https://github.com/ninenines/cowboy/issues/139) about getting this error when using atoms inside headers. Do you pass headers manually somewhere in your code? – tkowal Aug 04 '16 at 05:13
  • Are we talking about headers in an incoming request that Phoenix is receiving, or are we talking about headers in an outbound call that my server is making? Also, it mentions :undefined in the call to http_transport.close(). Is that the atom it doesn't like? It suggests to me an error upstream. Something was supposed to get a value but got :undefined instead. But I have no idea where to look to find that. – Matt Aug 04 '16 at 12:48

2 Answers2

2

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.

Sam
  • 1,548
  • 1
  • 10
  • 7
0

This is generated in io.c, part of the beam emulator.

I suspect it is generated when the remote end closes the tcp pipe.

The code is:

static void
badsig_received(int bang_op, Port *prt,
        erts_aint32_t state,
        int bad_output_value) {
    /*
     * if (bang_op)
     *   we are part of a "Prt ! Something" operation
     * else
     *   we are part of a call to a port BIF
     * behave accordingly...
     */
    if (!(state & ERTS_PORT_SFLGS_INVALID_LOOKUP)) {
    if (bad_output_value) {
        erts_dsprintf_buf_t *dsbufp = erts_create_logger_dsbuf();
        erts_dsprintf(dsbufp, "Bad value on output port '%s'\n", prt->name);
        erts_send_error_to_logger_nogl(dsbufp);
    }
    if (bang_op)
        send_badsig(prt);
    } /* not invalid */
} /* behaved accordingly */
tony wallace
  • 135
  • 6