[erlang-questions] my socket can't handle the load

Per Hedeland per@REDACTED
Sat Jun 5 12:31:58 CEST 2010


Pablo Platt <pablo.platt@REDACTED> wrote:
>
>I was able to identify exactly when the issue happens.
>As long as only one request at a time is sent to the driver it works fine:
>request1, response1, request2, response2...
>
>If the client sends several requests as fast as it can without waiting for a response it breaks.
>debug messages show the following:
>request1, request2, response1, request3, response2, Error timeout for request3, response3

I think the problem is just that while your handle_info() callback tries
to handle incomplete responses and additional data (and presumably you
have some framing to allow you to do that), you never process more than
one response per handle_info() invocation. I.e. what is happening here
is most likely that the complete response3 arrives concatenated onto
response2, but you don't process it - I believe you will find response3
sitting in State#state.resp. The fix is then (of course) to keep
processing the data you received until there are no more complete
responses. (I'm assuming that you can't make use of some variant of the
nice 'packet' option, see inet:setopts/2.)

--Per Hedeland


More information about the erlang-questions mailing list