[erlang-questions] erlang http tcp_closed problem
Sverker Eriksson
sverker.eriksson@REDACTED
Wed Feb 18 16:49:07 CET 2015
I would guess that you get a {tcp_error, Socket, emsgsize} message,
which you ignore in your _Else clause.
About packets being rejected even though {packet_size,0} is default. I
would consider this a documentation bug maybe. I don't think we want to
change the default behavior to be vulnerable agains DoS attacks with
insane long http lines in need of buffer space.
/Sverker, Erlang/OTP
On 02/18/2015 03:57 PM, Zandra Hird wrote:
> Hi,
>
> It might have to do with some internal buffer limitation (see doc
> http://www.erlang.org/doc/man/inet.html), so you can try to set
> packet_size to big enough to handle the large cookie header and see if
> it helps.
>
> / Zandra
>
>
> On 2015-02-12 10:36, Przemysław Wycisk wrote:
>> The reason of that behaviour was option packet_size on socket.
>> Default set of this option ({packet_size, 0}) should mean no size
>> (line size in http) limit shouldn't it?, but packets were dropped
>> because of large cookie header.
>> I consider it as a bug, and also i think that if line size limit in
>> http socket occurs i should get http_error instead of tcp_closed,
>> it's quite confusing.
>>
>> On Sun, Feb 8, 2015 at 7:25 PM, Przemysław Wycisk
>> <p.wycisk@REDACTED <mailto:p.wycisk@REDACTED>> wrote:
>>
>> I've got problem with using erlang active http socket.
>>
>> I receive msgs like that:
>>
>> ok = inet:setopts(Sock,[{active, true}]),
>> receive
>> {http, Sock, {http_request, HttpMethod, {abs_path, Path},
>> _HttpVersion}} ->
>> Headers = getHeaders(Sock),
>> %more code
>>
>> and then headers like that:
>>
>> getHeaders(Sock, Headers) ->
>> receive
>> {http, Sock, {http_header, _Num, 'Content-Length', _, Value}} ->
>> NewHeaders = Headers#'headers'{contentLength = Value},
>> getHeaders(Sock, NewHeaders);
>> {http, Sock, {http_header, _Num, 'Host', _, Value}} ->
>> NewHeaders = Headers#'headers'{host = Value},
>> getHeaders(Sock, NewHeaders);
>> {http, Sock, {http_header, _Num, 'User-Agent', _, Value}} ->
>> NewHeaders = Headers#'headers'{userAgent = Value},
>> getHeaders(Sock, NewHeaders);
>> %more headers here
>> %
>>
>> {http, Sock, {http_error, Error}} ->
>> ?LOG_INFO("protocol", "http returned error with reason:~p~n",
>> [Error]),
>> exit(normal);
>> {http, Sock, http_eoh} ->
>> Headers;
>> {tcp_closed, Sock} -> %<a mark>
>> ?LOG_INFO("connection", "Socket ~w closed by client", [Sock]),
>> exit(normal);
>> _Else ->
>> getHeaders(Sock, Headers)
>> end.
>>
>>
>> Normally it works fine, packets and headers are received from
>> browser and everyone is happy, but there is a case, when a browser
>> sends a request, and then i get "tcp_closed" in place where <a
>> mark> is placed, in the middle of receiving headers.
>>
>> This behaviour is strange for me, because it never happens in
>> incognito mode. That could mean that bowsers cache is involved in
>> the problem, but how?
>>
>> Anyone had the same problem? Anyone could help? I would be grateful.
>>
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150218/a2592672/attachment.htm>
More information about the erlang-questions
mailing list