-1

I'm writing a client-server application (client in AS3-AIR, server in C#).

After establishing connection they can transfer files to each other, etc. All good.
However, if the socket connections have a long break (while they are still connected), connection stops sending data.

It's weird, because the ActionScript socket ".connected" returns true. Same for the C# server.
Did anybody face this problem?

Eitan T
  • 32,660
  • 14
  • 72
  • 109
user1480049
  • 1,109
  • 2
  • 7
  • 3
  • 3
    Any NAT router in between that may have timed out? It is generally a bad approach to NOT send regular pings or other informative packets over a TCP socket to make sure both sides are still there. – TomTom Jun 30 '12 at 11:23
  • How long a break are we talking about? Seconds? Or days? And what actually happens when you try to send? Do you get an error? – David Schwartz Jun 30 '12 at 11:24
  • @TomTom That's what Tcp Keep Alive is for; – GETah Jun 30 '12 at 11:26
  • POST CODE or would you rather everyone keep guessing? – The_asMan Jun 30 '12 at 12:49
  • what code? Write simple application with tcp sockets on as3 and here the code. Sockets have same behavior at any kind of applications – user1480049 Jun 30 '12 at 13:18
  • @GETah yes, but if the app does not send it you are - at a loss. And I often send sensible small information there. There is a reason a LOT of protocols define a protocol level keep alive signal, for example FIX. – TomTom Jun 30 '12 at 13:28
  • @user1480049 You can't just write a simple socket connection you are probably losing connection because of the crossdoamin.xml issue but we can not tell because there is no code to look over. I see you are new here but if you have a question it would be best to post all relevant data to your issue this includes server side and client side code. As stated above there are a lot of things going on with a socket connection it is not as simple as writing a simple app with TCP sockets. – The_asMan Jun 30 '12 at 14:51
  • @TomTom That is not true. Keep alive packets are automatically sent by your OS, that is part of the TCP protocol :) – GETah Jun 30 '12 at 15:55
  • Ah, NO. Really. Read the spec. They are optional. Plus you do not know the interval - and it may be too long for a device. Plus often you dont want to wait, you want to KNOW something is bad. As I said, learn - read the fix specs, it goes in great detail on the use of this. – TomTom Jun 30 '12 at 16:22
  • Check http://stackoverflow.com/questions/1480236/does-a-tcp-socket-connection-have-a-keep-alive for more discussion on that. Nice half-knowledge you turn around here. Keepalive standard interval is often way longer than what NAT devices prefer. – TomTom Jun 30 '12 at 16:25

1 Answers1

0

I'd suggest sending ping (and replying pong) every 10 seconds.

Evgeny Lazin
  • 9,193
  • 6
  • 47
  • 83
www0z0k
  • 4,444
  • 3
  • 27
  • 32