cowboy connection process terminated with enomem

427 Views Asked by At

I encountered an cowboy error

Ranch listener api_resource had connection process started with cowboy_protocol:start_link/4 at <0.1822.0> exit with reason: enomem#012

In the request handler, I'm interacting with another vendor's tts platform, via erlang port(c language). The first tts command to the port succeeded, I can got 1M bytes data, the second tts command to the port is sent to the port successfully, but then the cowboy process terminated immediatedly with the error message above.

I've tried to raise erlang vm's stack size, heap size, binary virtual heap size, and os's stack size, no help.

Any suggestion is appreciated, thanks.

code:

tts(Port, Params, Text) ->
    case call_port(Port, {'set_tts_params', Params}) of
        {'error', _}=Error -> Error;
        _ -> slice_tts(Port, slice_text(Text), <<>>)
    end.

slice_tts(_Port, [], Acc) ->
    lager:debug("tts over"),
    {'ok', <<"RIFF", (byte_size(Acc)+36):32, "WAVE", "fmt ", 16:32,
            1:16, 1:16, 16000:32, 32000:32, 2:16, 16:16,
            "data", (byte_size(Acc)):32, Acc/binary>>};

slice_tts(Port, [Text|Others], Acc) ->
    lager:debug("ttsing ~p bytes", [byte_size(Text)]),
    case call_port(Port, {'tts', Text}) of
        {'error', _}=Error -> Error;
        {'ok', Data} -> slice_tts(Port, Others, <<Acc/binary, Data/binary>>)
    end.
0

There are 0 best solutions below