We have a custom listener on our WCF solution, which inherits from ChannelListenerBase<IDuplexSessionChannel>.
We have a badly-behaved client (out of our control), which has a TCP conversation with us along the following lines:
SYN
SYN,ACK
RST
Basically, they’re trying to perform operations on the socket before it’s established, failing, and closing the socket.
In our OnEndAcceptChannel code, we end up not being able to create a channel, because the underlying Socket has already been closed by the time we get there, and we get a SocketException. This then seems to kill the listener dead, stopping it accepting further connections.
From OnEndAcceptChannel, we’ve tried returning null, throwing the Exception, and Faulting the listener so that it can be restarted higher up the call stack. The latter is the only solution we’ve found that will allow the channel to effectively keep on listening, but that has the unpleasant (& unacceptable) side effect of killing all established connections to the service.
Anybody got any suggestions of how to handle this situation, keep listening, and not lose established connections…?
We managed to fix it in the end. Instead of returning null, we returned an instance of a dummy class implementing
IDuplexSessionChannelthat is essentially a dumb state machine, and nothing more – fools WCF into carrying on regardless.