Re: how to handle socket timeout?



Arkadiy <vertleyb@xxxxxxxxx> writes:
On Jan 15, 11:03 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:

[...]

I think this model allows me to achieve the goal of "fast result or no
result". The notion of "fast" is configurable by the timeout value.

Let's say I setup all the facility on the LAN, and the server's
average response time is 0.1 msec. If I set the timeout to, for
example, 1 msec, everything will go smoothly most of the time. When I
get a timeout, this may mean one of a few things:

1) The server became unreachable. I want to close the socket and
start attempts to reconnect;

This will result in a FIN being transmitted to the server, after which
the kernel waits for a FIN-ACK coming from there and sends an ACK. If
the server is unreachable, this will not work, and if it is just
responding slowly, your close request will be processed after all
other requests you have sent and the connection will be closed after
you have processed all replies to these requests (this is the default
behaviour, hackarounds would be possible).

2) Accidentially long response. Still nothing wrong with
reconnecting, since this happens rearly (how rarely -- can be
controlled by the value of the timeout);

This is actually situation 3: The server cannot reply fast enough.

3) Server is congested. This is the worst case. But, IMO, this is
the case where nothing can be done. Except adding another server
instance to split the load.

The easy thing which could be done is to not increase the load in the
server by torturing it with completely useless connection teardown and
re-establishment requests.

4) Network is congested. Again, I don't see what can be done in this
case.

Same as above. Avoid injecting more useless packets.

To repeat this again: TCP is a reliable bytestream protocol based on
persistent virtual circuits. Either you want a reliable bytestream
protocol, then you should just be using it, or you don't want a
reliable bytestream protocol and then don't use it.

For practical purposes, the daemon you are talking to is closely
similar to a network file system server and the way you want to use it
would lend itself to the 'traditional' way NFS worked: Assume the
server is stateless (gets around all possible issues with crashes
etc), send a request using UDP when you want to request some data,
possibly, retransmit that a couple of times using a 'standard'
exponential backoff algorithm and process eventual replies when and if
they arrive, dropping whatever you don't want anymore.

This is exactly the same procedure one would sensibly use for TCP,
except that it is not necessary to deal with connections anymore.

[...]

Am I missing something?

An introduction in internetworking protocols, maybe?
.



Relevant Pages

  • Re: Timeout problems
    ... I am assuming that the time out is a scripting timeout on your browser. ... we have a request to the SQL Server ... database to run a stored procedure to return the data. ...
    (microsoft.public.dotnet.general)
  • Re: Fehler "Der gefundene Anforderungstyp ist text/html; charset=utf-8, aber text/xml wurde erw
    ... Was sind denn in dieser Konstellation sinnvoll Werte für das Timeout? ... Das lässt sich nicht so allgemein sagen, da es vom Umfang der Seiten abhängt ... Request 15 Sekunden braucht, ... Dann schwitzt der Server schon recht. ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • Re: WebRequest.Timeout bugs?
    ... I've found that if the server accepts the request, ... but we thought that by putting a timeout on the ... > response due to the way our authentication works. ...
    (microsoft.public.dotnet.framework.compactframework)
  • WebRequest.Timeout bugs?
    ... The server is accepting web requests, ... but then not responding to them. ... a way that the first request is rejected with a 401 ... The first request works fine with a suitably high timeout, ...
    (microsoft.public.dotnet.framework.compactframework)
  • [REVS] NTLM HTTP Authentication is Insecure By Design
    ... in front of a web server, and that proxy server shares a single TCP ... These are attacks that make use of non-RFC HTTP requests (HTTP Request ... the authentication is associated with the ...
    (Securiteam)