1.1.9.6 Repeater disconnects waiting servers and clients

Developers may discuss here.

1.1.9.6 Repeater disconnects waiting servers and clients

Postby kobruleht » 2014-02-23 09:35

1.1.9.6 repeater is running in Mode II in windows Vista.
After every 10 minutes waiting servers and waiting client are disconnected.

do_repeater_wait in in socket_functions.cpp outputs to log

recv -1

I added printout after that and found that error was

10038 An operation was attempted on something that is not a socket.


It looks like after every 10 minutes sockets are destroyed, socket handles become invalid and recv returns this error.

I added timeouts printouts after socket creation using procedure below.
This prints out 0 so it looks like socket timeouts are infinite.
I tried ultravnc server running in same computer as repeater and enabled keepalive. This server gots also disconnected so it looks like this is not router issue.

How to fix it ro find reason of socket disconnection?

Code: Select all
static void veateade_TIMEO(char *txt, SOCKET sock)
{
        // code from http://www.cs.cmu.edu/afs/cs/academic/class/15213-f00/unpv12e/sock/sockopts.c
   struct timeval   timer;
   int optLen = sizeof(timer);
   timer.tv_sec = timer.tv_usec = 0;
   optLen = sizeof(timer);
   if (getsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timer, &optLen) != 0)
         debug("veateade_TIMEO(SO_RCVTIMEO): ");
   else
      debug("veateade_TIMEO() => SO_RCVTIMEO = %ld.%06ld\n", timer.tv_sec, timer.tv_usec);
   timer.tv_sec = timer.tv_usec = 0;
   optLen = sizeof(timer);

   if (getsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timer, &optLen) != 0)
      debug("veateade_TIMEO(SO_SNDTIMEO): ");
   else
      debug("veateade_TIMEO() => SO_SNDTIMEO = %ld.%06ld\n", timer.tv_sec, timer.tv_usec);
}
kobruleht
8
8
 
Posts: 14
Joined: 2014-01-26 15:51

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby Rudi De Vos » 2014-02-25 10:24

I don't think you can keep a socket infinite open without sending data, some OS mechanism seems to close it.
SO_RCVTIMEO, SO_KEEPALIVE doesn't seems to prevent it.

The only way is changing the protocol, and sending some keepalive message. ( between vnc and repeater while in waiting state)
The problem is that this would break the current rfb protocol, and after adding this we would loose any compatibility between vnc flavors.
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5294
Joined: 2004-04-23 10:21

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby kobruleht » 2014-02-25 15:16

Hi,

I tested with 10 servers from different Windows OS-es using

Code: Select all
[admin]
service_commandline=-id:10xx -autoreconnect -connect repeater.com:60005
KeepAliveInterval=5


After every 10 minutes, when all waiting connections are closed, only few of them appear back immediately. It takes long time for most servers to autoconnect back.

In windows there is no 10 minute disconnect timeout described in any documentation. Default timeout is 0, listen connection should listen forever.
All servers are disconnected at same time. Windows system log does not contain any entry.
So it should be some other thing.

How to find reason of this ?
kobruleht
8
8
 
Posts: 14
Joined: 2014-01-26 15:51

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby Rudi De Vos » 2014-02-25 16:05

Because they all disconnect i guess it's the socket cleanup, that's done every x seconds.
Problem:
The server is connected to the repeater in a recv() state.
If the server close his sockets he doesn't send anything to the repeater, he just close the connection.
The repeater is wating for a viewer ...he doesn't exchange any data with the server until a viewer is connected.
After a while you get a lot of ghost processes, this is avoided with a cleanup,
but the cleanup seems also to close the good "waiting" connections.

As it seems you can debug the code, look at the cleanup part try to play with the timeout
( Look for gettickcount() in the src, it have te be around this function that the timeout is set)
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5294
Joined: 2004-04-23 10:21

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby kobruleht » 2014-02-25 20:32

Hi,

Thank you.

I changed line

Code: Select all
if (tick-Servers[i].timestamp>300000 && Servers[i].used==false && Servers[i].code!=0)


to 10x longer:

Code: Select all
if (tick-Servers[i].timestamp>3000000 && Servers[i].used==false && Servers[i].code!=0)


It looks like 10 minute disconnect does no more occur.

Unfortunately after restaring repeater process from control panel servers re-connect back with long delay:

Waiting servers:

Slot Time ID nummer Connection from comment
0 2014/2/25 22:6:53 1013 x.x.x.x testserver1
1 2014/2/25 22:8:3 1009 127.0.0.1 localtestserver
2 2014/2/25 22:8:41 1005 x.x.x.x testserver2
3 2014/2/25 22:8:43 1000 x.x.x.x testserver3
4 2014/2/25 22:18:43 1004 x.x.x.x testserver4
5 2014/2/25 22:18:50 1007 x.x.x.x testserver5
6 2014/2/25 22:18:52 1003 x.x.x.x testserver6
7 2014/2/25 22:18:53 1001 x.x.x.x testserver7
8 2014/2/25 22:18:55 1006 x.x.x.x testserver8
9 2014/2/25 22:35:40 1014 x.x.x.x testserver9


Servers have autoreconnect and keepalive set. Reconnect should occur immediately.
However it takes 12 minutes for testserver4 .. 8 to appear and 29 minutes for testserver9 to appear.

Only way to force immediate connect is to re-start server service in client computer.

How to force servers to re-connect immediately to repeater ?

Andrus.
kobruleht
8
8
 
Posts: 14
Joined: 2014-01-26 15:51

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby Rudi De Vos » 2014-02-25 23:14

I don't know if this is possible,
The intention was that the repeater stay online.

Servers have autoreconnect and keepalive set
autoreconnect: Only works if disconnect is detected. The repeater need to proper close the sockets, don't know if the repeater does it.
keepalive: is used for filetransfer

Increasing the timeout is just a fast solution, socket should be tested to see if they are still connected.
I need to make time to check this again, but first want to finish some logmein alternative.
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5294
Joined: 2004-04-23 10:21

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby kobruleht » 2014-02-26 14:52

Thank you.

Will servers autoreconnect faster if KeepAlive socket option is active ?
If yes, how to enable KeepAlive between UVNC server and repeater ? KeepALive interval can be some minutes in this case.
kobruleht
8
8
 
Posts: 14
Joined: 2014-01-26 15:51

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby Rudi De Vos » 2014-02-26 19:38

Keepalive is an internal value for Filetransfer, doesn't help for the socket.
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5294
Joined: 2004-04-23 10:21

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby kobruleht » 2014-02-26 20:19

Should I modify server connecting socket creation so that KeepAliveInterval parameter is also used
for back connections ?

In this case socket die returns immediately error to server and server will re-connect back immediately?
kobruleht
8
8
 
Posts: 14
Joined: 2014-01-26 15:51

Re: 1.1.9.6 Repeater disconnects waiting servers and clients

Postby Rudi De Vos » 2014-02-26 22:28

You can try to add the so_keepalive parameter, but i don't think it gonna make a difference.

Verify that the repeater call closesocket when you stop the repeater.
If repeater is stopped without socket closing, the other site is never notified
that the socket is closed and keep waiting for new data.
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5294
Joined: 2004-04-23 10:21


Return to Developer discussions (mainly user-mode)

Who is online

Users browsing this forum: No registered users and 1 guest