You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Irving, Dave" <da...@logicacmg.com> on 2006/02/23 16:37:42 UTC

[OT] Weird NIO behaviour with load balancers / port scanners

Hi,

This is just an observation really - just incase someone else stumbles
across the issue and wonders whats going on :o)
I was seeing a large number of exceptions coming from Mina in one of my
deployments recently - which basically took three flavours:

[1]
java.lang.Error: java.net.SocketException: Invalid argument
	at sun.nio.ch.Net.localAddress(Net.java:127)
	at
sun.nio.ch.SocketChannelImpl.localAddress(SocketChannelImpl.java:390)
	at
sun.nio.ch.SocketAdaptor.getLocalAddress(SocketAdaptor.java:142)
	at java.net.Socket.getLocalSocketAddress(Socket.java:640)
	at
org.apache.mina.io.socket.SocketSession.<init>(SocketSession.java:80)
	at
org.apache.mina.io.socket.SocketAcceptor$Worker.processSessions(SocketAc
ceptor.java:315)
	at
org.apache.mina.io.socket.SocketAcceptor$Worker.run(SocketAcceptor.java:
244)

[2] (Before anything had actually been read or written)
java.io.IOException: Connection reset by peer
	at sun.nio.ch.FileDispatcher.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
	at sun.nio.ch.IOUtil.read(IOUtil.java:200)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
	at
org.apache.mina.io.socket.SocketIoProcessor.read(SocketIoProcessor.java:
265)
	at
org.apache.mina.io.socket.SocketIoProcessor.processSessions(SocketIoProc
essor.java:238)
	at
org.apache.mina.io.socket.SocketIoProcessor.access$200(SocketIoProcessor
.java:42)
	at
org.apache.mina.io.socket.SocketIoProcessor$Worker.run(SocketIoProcessor
.java:555)

[3]
java.io.IOException: No buffer space available
	at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
	at
sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:1
34)
	at
org.apache.mina.io.socket.SocketAcceptor$Worker.processSessions(SocketAc
ceptor.java:304)
	at
org.apache.mina.io.socket.SocketAcceptor$Worker.run(SocketAcceptor.java:
244)

Anyway, it turned out the problem was a load balancer / port scanner
which was initiating connections and then immediately dropping them:

Scanner                         Mina App
SYN      -------------------->
         <-------------------   SYN / ACK
ACK      -------------------->
RST/ACK  -------------------->

I.e, as soon as a connection was established, it was getting slammed
shut.
Its probable that which exception gets thrown depends on how far through
setting up the local socket stuff the OS gets through before it realises
the connection has been blown.

Anyway, in all cases, as I'd expect, Mina does exactly the right thing
(reports the exception, ditches the channel), and continues to serve
"proper" connections with its usual excellence.

However, just incase anyone else stumbles across these weird exceptions
in your logs - you could have a dodgy load balancer / port scanner in
the midst :o)

All the best,

Dave


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.