Closed twittner closed 10 years ago
Hey man, thanks for finding this issue. I thought about this for a while and I think your solution will solve the issue. Appreciate it! :+1:
Would it be possible for you send me a pull request for this? That way you get proper accreditation.
In addition to the above I propose to reset the timeout on incoming data (i.e. in copyIterateeToMVar
). Otherwise clients which are busy sending data but are not replying with a pong will be disconnected.
If the frequency of
ping
s generated byforkingPingThread
is higher than Snap's default timeout, the connection will stay alive even if clients never send anything back to the server. The reason for this is that every time aping
is send Snap will tickle the timeout (cf. SimpleBackend.hs, in particular the functionwriteEnd
).Instead it would be preferable to set the tickle timeout to a value less than the thread delay, for example:
If clients should be given a second chance one could use a flag (or counter) between the ping thread and
connectionOnPong
and only reduce the tickle timeout on the second (or nth) attempt.