I'm also a newbie, but this raises an interesting "design pattern" question:
Would this heartbeat/watchdog function be something that would be a good fit for a "filter"? That is, a class/thread that keeps a watchdog timer that gets reset whenever a packet is received from the remote end; if/when the timer triggers, this filter would send a heartbeat packet back down the chain, which should cause a response from the remote end. If the watchdog timer triggers twice in a row, you know something is backing up the plumbing, without having to complicate the codecs or business logic. The only "cost" is that both the client and the server would need to patch in compatible heartbeat filters... -John On Sun, Dec 19, 2010 at 6:23 PM, Mark Harris <[email protected]> wrote: > Hello, > > I have a Mina application (v 1.1.7) which sends and receives messages to > and from a server. > > I'm trying to make it as resilient as possible. One scenario I've found > is where a connection is successfully made to a server, then network > connectivity is lost. If I try and send a message to the server > immediately after this, the client just hangs. I was hoping to add a > timeout to the code that actually sends the message and receives a > response, but looking through the Net, examples use either TimerTask or > ExecutorService objects which - due to their being inner classes - mean > that I can't seem to get a hold on the response object to return. > > Just wondered whether anyone else has been in a similar scenario and if > so how they managed to fix the problem. > > Thanks, > > Mark >
