soundmud / soundrts

A real-time strategy audio game
http://jlpo.free.fr/soundrts
Other
44 stars 32 forks source link

Added TCP keepalive #86

Closed ctoth closed 7 years ago

ctoth commented 7 years ago

This should go a long way towards preventing the connection from silently dropping. Fixes #85

soundmud commented 7 years ago

Since this is Windows specific, I will probably add a platform test or maybe just a "try: except: pass" to avoid an error in a Linux client for example.

ctoth commented 7 years ago

Is this actually only Windows-specific, and if so, how do we get it to work for other operating systems? Ping @tspivey

On 11/17/2016 5:22 PM, soundmud wrote:

Since this is Windows specific, I will probably add a platform test or maybe just a "try: except: pass" to avoid an error in a Linux client for example.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261412407, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOcCIVe4C4VX6pxRiNDOqnkzy-pOmqpks5q_O-8gaJpZM4J_gby.

    -Q

Accessible Software for the Blind

http://GetAccessibleApps.com

soundmud commented 7 years ago

According to the Python manual:

socket.ioctl(control, option) Platform: Windows

Other operating systems are probably very rare right now, except maybe on the server side.

Anyway it's probably possible to solve the problem on a higher level by having the server asking "are you alive?" from time to time, or the client just saying "I'm here".

Does the disconnection happen in a specific menu or during a game or during chat?

I will probably work on the server soon so I might stumble on a solution.

tspivey commented 7 years ago

This is OS specific. Windows, Linux and Mac OS each have different ways of doing this. see this example code - I haven't tested it, and the values will have to be changed.

ctoth commented 7 years ago

The actual drops happen at all sorts of times.

If I just leave a client up connected to a server and come back in a few hours I can expect it to be dropped, but the client doesn't yet know it.

I also get frequent drops in long-running games, but this may be something else entirely.

On 11/17/2016 5:54 PM, soundmud wrote:

According to the Python manual:

socket.ioctl(control, option) Platform: Windows

Other operating systems are probably very rare right now, except maybe on the server side.

Anyway it's probably possible to solve the problem on a higher level by having the server asking "are you alive?" from time to time, or the client just saying "I'm here".

Does the disconnection happen in a specific menu or during a game or during chat?

I will probably work on the server soon so I might stumble on a solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261417618, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOcCIzi8kN35DhoAuBmtqG2lzijuM9Lks5q_PcogaJpZM4J_gby.

    -Q

Accessible Software for the Blind

http://GetAccessibleApps.com

sanslash332 commented 7 years ago

I think that the better option, to the server knows if a client is keep connected or not, is thtat the client poll to the knouing conections if they are alive. A simply question, every X frames that the server wait for a answer.

If the client doesn’t answer in a period of time, the server consider disconnected that client and drop it.

From: Christopher Toth [mailto:notifications@github.com] Sent: jueves, 17 de noviembre de 2016 22:05 To: soundmud/soundrts soundrts@noreply.github.com Subject: Re: [soundmud/soundrts] Added TCP keepalive (#86)

The actual drops happen at all sorts of times.

If I just leave a client up connected to a server and come back in a few hours I can expect it to be dropped, but the client doesn't yet know it.

I also get frequent drops in long-running games, but this may be something else entirely.

On 11/17/2016 5:54 PM, soundmud wrote:

According to the Python manual:

socket.ioctl(control, option) Platform: Windows

Other operating systems are probably very rare right now, except maybe on the server side.

Anyway it's probably possible to solve the problem on a higher level by having the server asking "are you alive?" from time to time, or the client just saying "I'm here".

Does the disconnection happen in a specific menu or during a game or during chat?

I will probably work on the server soon so I might stumble on a solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261417618, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOcCIzi8kN35DhoAuBmtqG2lzijuM9Lks5q_PcogaJpZM4J_gby.

-Q

Accessible Software for the Blind http://GetAccessibleApps.com

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261419505 , or mute the thread https://github.com/notifications/unsubscribe-auth/AA-aGyhkUGVlH60kcwTpPT7eeMoXQ5kKks5q_PnUgaJpZM4J_gby .

ctoth commented 7 years ago

I strongly feel that using the existing tcp keepalive mechanism is far preferable to actually implementing our own ping pong handler. Furthermore, your message here reminds me of another rather serious issue: In more complicated games that have a lot going on, often times I will get disconnected and didn't yet know why until today. The problem is the existing timeout handling code, and I will open a new issue about this. Basically it closes the connection without warning if the client is too busy to respond fast enough, which is basically what you're proposing here all over again. This means that there are more games than I can count that were prematurely ended by the timeout misfeature, making many people sad.

On 11/17/2016 9:20 PM, Sandl Okino wrote:

I think that the better option, to the server knows if a client is keep connected or not, is thtat the client poll to the knouing conections if they are alive. A simply question, every X frames that the server wait for a answer.

If the client doesn’t answer in a period of time, the server consider disconnected that client and drop it.

From: Christopher Toth [mailto:notifications@github.com] Sent: jueves, 17 de noviembre de 2016 22:05 To: soundmud/soundrts soundrts@noreply.github.com Subject: Re: [soundmud/soundrts] Added TCP keepalive (#86)

The actual drops happen at all sorts of times.

If I just leave a client up connected to a server and come back in a few hours I can expect it to be dropped, but the client doesn't yet know it.

I also get frequent drops in long-running games, but this may be something else entirely.

On 11/17/2016 5:54 PM, soundmud wrote:

According to the Python manual:

socket.ioctl(control, option) Platform: Windows

Other operating systems are probably very rare right now, except maybe on the server side.

Anyway it's probably possible to solve the problem on a higher level by having the server asking "are you alive?" from time to time, or the client just saying "I'm here".

Does the disconnection happen in a specific menu or during a game or during chat?

I will probably work on the server soon so I might stumble on a solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261417618, or mute the thread

https://github.com/notifications/unsubscribe-auth/AAOcCIzi8kN35DhoAuBmtqG2lzijuM9Lks5q_PcogaJpZM4J_gby.

-Q

Accessible Software for the Blind http://GetAccessibleApps.com

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261419505 , or mute the thread https://github.com/notifications/unsubscribe-auth/AA-aGyhkUGVlH60kcwTpPT7eeMoXQ5kKks5q_PnUgaJpZM4J_gby .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/soundmud/soundrts/pull/86#issuecomment-261445381, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOcCHJYpmjE08Hy0iYtsuGeHFuwCPTkks5q_SeMgaJpZM4J_gby.

    -Q

Accessible Software for the Blind

http://GetAccessibleApps.com

soundmud commented 7 years ago

99% of the clients are on Windows, and the issue isn't as serious as the latest one you mentioned. So I will merge this pull request and add a "try: except: pass" to preserve clients with other operating systems just in case.