Remy, thanks.
Here is a more detailed explanation
D7, Indy 9.0.18, Problemous clients - Windows XP or 98, Server - Win 2003
Std
Each client establishes 2 connections to the server (there are two different
thread classes on the server)
There are 2 IDTCPservers listening on two different ports.
The application is actually a chat/voice classroom.
The first connection established has some control purposes and it has a
ping/pong mechanism
the second connection carries voice over tcp
So the one with the ping/pong never gets disconnected unless a network
problem but in case in a network problem the two of them get disconnected
wich is OK.
The second one, however as described (this is the audio) has no ping/pong
and what actually happens
When a client connects to the server with the control connection it is
authenticated and short after that the "audio" connection is established.
The reader thread enters a it "while not terminated" loop
audioconn.readbuffer(....)
There is no read timeout. It reads untill disconnected or data arrives.
Usually initially there is no activity data transfered over the "audio"
connection. (Think of students entered the classroom and waiting for the
teacher to start).
When the server starts sending data over this connection some of clients
indicate their "audio" connection is disconnected.
It is hard to trace but the server logs show the exception "Disconnected"
and the client log shows that the thread has exited because of the client
socket has disconnected.
In a session with 50 users there are usually 3-5 of them with this problem.
The logs show that it usually takes 14 or 15 minutes from the time they
first connect till the time they get disconnected.
To mention here that their "audio" connection never gets disconnected while
data is transfered. i.e. when not idle. It happens that a presenter may
speak for 1 or 2 hours and they have no problems. Only when nothing is sent
for more than 14/15 minutes (i.e. when he turns off his micorphone) and
starts again there are complaints about that.
Sorry for involving you with these details but I just want to give more lite
on this.
The problemous connections report remote ports in the high range above 50000
and IP locations show different countries (India, Australia, China). Never
USA, Europe. (but I doubt it has something in common)
So to summarize:
The connection with a ping/pong never gets disconnected
The connection without a ping/pong gets disconnected when idle for more than
14/15 minutes but never disconnected when not idle no matter how long
Most likey there is a router and/or a proxy or a firewall.
I hope this give more lite.
As far as the architecture is concerned. I mentioned above
Two servers litening on two ports. Each one has a custom thread class.
Per user queue is available. A separate "writer" thread for each client
connection on the server to send data (to avoid blocking). Well there is
nothing special about design. Actually one sends to server. Data is queued
for each client and then each client's writer thread takes care about
sending. So I really think it is not a design issue but has something to do
with the routers.
Yesterday we implemented ping/pong and will be monitoring this.
Thanks
"Remy Lebeau (TeamB)" <
XXXX@XXXXX.COM>writes
Quote
"York" <XXXX@XXXXX.COM>writes
news:44ffb24a$XXXX@XXXXX.COM...
>The data however comes in different intervals of time. Between
>each data packet there may be 2, 10, 15 or more minutes.
That is not a good design choice. If the server is not going to send
actual
data for long periods of time, then you should have the server send
keep-alive packets at regular intervals during the idle periods. This
way,
the client will be able to tell if the server is still active. If the
client does not receive any packets from the server after a suitable
period
of time, then the client can assume that the server is dead so that it can
reconnect the connection.
However, I should also mention that if the client sends no data to the
server at all, then the server has no way of detecting dead clients in a
timely manner. If you can, you should have your clients send keep-alive
packets to the server (and have the server reply to them). This way, the
server knows that each client wants to keep the connection active.
>Sometimes we noticed that a few number of our clients are disconnected
>from the server. The server triggers an OnException event with the
>message "Disconnected"
Without knowing exactly what your code is doing, I can only guess that
maybe
you probably had a network failure for those connections.
>This only happens when the interval between the data packets is long
enough.
Are you using timeouts in your reading/writing?
>My guesses are that "something" causes the connection to disconnect
>when no activity.
Sockets do not do that. However, if the connections are going through a
firewall or a network router, they might be closing idle connections to
reclaim unused resources.
>Is this likely to happen when no activity over a TCP connection?
Under normal situations, no.
>It does not happen for all of the client but only for a small percentage
>(about 10-15%)
Can you isolate what is different about those clients and/or their
environments?
>Will a ping/pong mechanism solve the problem?
Most likely, yes.
Gambit