Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clients not being cleaned up properly #145

Closed
UriHendler opened this issue Feb 9, 2017 · 5 comments
Closed

clients not being cleaned up properly #145

UriHendler opened this issue Feb 9, 2017 · 5 comments
Labels

Comments

@UriHendler
Copy link

When the TCP connection is dropped from the client side, Tile38 still keeps the client in its list of connections.

Here's an example when using tile38-cli:

  1. Start new client
    The Tile38 log shows the connection:
    2017/02/09 09:32:22 [DEBU] opened connection: 1.2.3.4:3086

  2. Let the client be idle for a minute or two. This causes the connection to timeout (not sure where this is set).

  3. Send a command.

  4. Client gives a TCP error message and exits, but the Tile38 log does not show an error or "closed connection" message. (At this point, the TCP port has been released to the OS, as expected.)

geofences.mydomain.test:9854> hooks geoFence*
read tcp 192.168.0.23:3086->tile38-server-ip-here:9854: wsarecv: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because connected host has failed to respond.

  1. Start another client.
  2. Run the CLIENT LIST command and the old client will still be there.
tile38-cli -h geofences.mydomain.test -p 9854

geofences.mydomain.test:9854> client list
id=57 addr=1.2.3.4:3086 name= age=740 idle=684

To check/fix:

  1. It seems the TCP connection timeout is set on the Tile38 side. Where/how is this configured?

  2. Are the clients being cleaned up when the TCP connection is dropped?

@tidwall
Copy link
Owner

tidwall commented Feb 9, 2017

I tried your instructions but I haven't been able to reproduce. I waited 10 minutes.

There aren't any timeouts defined on the Tile38 server-side. It's pretty basic actually. Just a listen/accept pattern.

Could you provide some details on your environment? If I can reproduce, then I can watch the packets on wire and see which side it's coming from.

Regardless of which side it's coming from though, perhaps we could set up keepalives on the TCP connections on the server. This would allow for the server to discover when a client drops off. The downside is that under-the-hood there's a little more traffic being sent around.

@tidwall
Copy link
Owner

tidwall commented Feb 9, 2017

In fact, I think we should just add keepalives.

@tidwall tidwall added the bug label Feb 9, 2017
@tidwall
Copy link
Owner

tidwall commented Feb 9, 2017

I'm marking this issue as a bug, because the server should be responsible for managing it's connections, and TCP keepalives were created for this purpose.

TODO: Add TCP keepalives after the server accepts a tcp connection. Set the default period to 300 seconds. Add a config option to define the period duration.

tidwall added a commit that referenced this issue Feb 9, 2017
Enabled TCP keepalive packets to determine if the connection is still
valid, and terminate if needed. It also helps with maintaining idle
connections.

Default to 300 seconds and can be changed by:

    CONFIG SET keepalive 300

addresses #145: clients not being cleaned up properly
@tidwall
Copy link
Owner

tidwall commented Feb 9, 2017

I just pushed an update to the master branch which should address this issue. Please test again and let me know. Thanks.

@tidwall
Copy link
Owner

tidwall commented Feb 21, 2017

@UriHendler I ran a few tests pulling over physical networks using cat-5 by hot unplugging cables and watching timeouts. The keepalive code seems to behave well.

I'm closing this as fixed for now. Feel free to reopen if you see any problems.

Thanks for you help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants