Hello.
I put mina 2 M4 to use in an RTP media endpoint.
I made a change to the mina code for handling Port Unreachable
Exception. I'm curious about your response.
Port Unreachable error is not unexpected in a media strea application.
In my testing of my application, I found that the media sender is
sending packets before the receiver has opened its udp port .(I think
this happens because in my test, network latency is down to
practically zero.) RTP expects to lose packets. If the receiver
doesn't have its port open yet, <<shrugs>> "oops :)". I think it
reasonable for the sender to expect that either the listener port will
become open, or an out-of-band request to shutdown the RTP traffic
will be received, so it should keep sending even when Port Unreachable
occurs.
Mina M4 AbstractPollingIoProcessor takes an opposite stance. On
PortUnreachableException (on a read), the IoSession is removed, and
consequently shutdown.
Here is code change that allowed my session to live beyond a few port
unreachable errors
AbstractPolliingIoProcessor line 601:
} catch (Throwable e) {
if (e instanceof IOException) {
if(! (e instanceof PortUnreachableException)) // my addition
scheduleRemove(session);
}
IoFilterChain filterChain = session.getFilterChain();
filterChain.fireExceptionCaught(e);
}
Any comments on the above?
With all due respect to the hard-working mina developers, I have two
other comments about the error handling here. Of course, please
disregard by your own discretion.
1) A design alternative: Maybe it would be more flexible for the
IoHandler to decide whether to remove the session on the basis of its
own exception handling rules. Isn't that what exceptionCaught is for?
2) (Take this with a really light grain of salt, as it is personal
preference). I'd disagree with handling java.lang.Throwable. My
IoHandler's caughtException will get java.lang.Error, which I really
cannot do anything about. Usually, I let the JVM melt down on
java.lang.Error on the theory that there isn't much error recovery
possible.
Regards,
John
P.S. Good work on mina 2. I was able to replace my own poor
implementation of nio handling with mina in about a day.