[erlang-questions] 8k limit on gen_tcp:recv?

Rachel Willmer <>
Fri Mar 19 15:20:04 CET 2010


Thanks to everyone who responded, this is all really useful.

Trying it now...
Rachel

On 11 March 2010 10:31, Tony Rogvall <> wrote:
> Note that setting the recbuf not only updates the inet driver read buffer but also
> the sets the SO_RCVBUF socket option. This is not always what you want!!!
> First consult the networking documentation on TCP and buffer management to
> see if this will result in unwanted behavior.
>
> If you do not know exactly what recbuf does you may instead use the option
> {buffer, Size} which only affects the inet driver read buffer
>
> /Tony
>
>
> On 11 mar 2010, at 04.43, Steve Vinoski wrote:
>
>> Try setting your socket's receive buffer to something larger than 8k
>> before you do the recv:
>>
>> inet:setopts(Socket, [{recbuf,16384}]).
>>
>> By passing a 0 for the length to recv, you're telling it to receive
>> all available bytes. I assume it can't receive more bytes than its
>> buffer can store.
>>
>> --steve
>>
>> On Wed, Mar 10, 2010 at 6:48 PM, Bob Ippolito <> wrote:
>>> Since this is definitely not clear in the question, the code would
>>> look something like this:
>>>
>>>    inet:setopts(Socket, [{packet, http}]),
>>>    case gen_tcp:recv(Socket, 0, ?IDLE_TIMEOUT) of
>>>        {ok, {http_request, Method, Path, Version}} ->
>>>            headers(Socket, {Method, Path, Version}, [], Body, 0)
>>>    end.
>>>
>>> Rachel - how about providing a reproducible test case and making it an
>>> issue in the mochiweb project? There might be some continuation
>>> response from recv that mochiweb doesn't currently expect to receive.
>>>
>>> http://code.google.com/p/mochiweb/issues/entry
>>>
>>> On Wed, Mar 10, 2010 at 3:40 PM, Rachel Willmer <> wrote:
>>>> I've been debugging a problem whereby couchdb rejects a URL longer than 8k.
>>>>
>>>> At first, I thought it was an already known limitation in mochiweb
>>>> (the stack is couchdb/mochiweb/erlang).
>>>>
>>>> But with large amounts of ioformat debugging, I've pinned it down to a
>>>> call from mochiweb to gen_tcp:recv which fails on this long URL.
>>>>
>>>> Is this a known limitation in erlang's gen_tcp:recv?
>>>>
>>>> Rachel
>>>>
>>>> ________________________________________________________________
>>>> erlang-questions (at) erlang.org mailing list.
>>>> See http://www.erlang.org/faq.html
>>>> To unsubscribe; mailto:
>>>>
>>>>
>>>
>>> ________________________________________________________________
>>> erlang-questions (at) erlang.org mailing list.
>>> See http://www.erlang.org/faq.html
>>> To unsubscribe; mailto:
>>>
>>>
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:
>>
>
>


More information about the erlang-questions mailing list