0
votes

Sometimes a client has to send a lot of SYN packets before Netty server is establishing a socket connection. As example see some packets made with tcpdump

12:23:30.166272 IP (tos 0x0, ttl 53, id 61857, offset 0, flags [DF], proto TCP (6), length 60)
SOURCE.25809 > DEST.7780: Flags [S], cksum 0x4bf4 (correct), seq 3364886260, win 5200, options [mss 1380,nop,wscale 0,nop,nop,TS val 264 ecr 0], length 0
12:23:54.067379 IP (tos 0x0, ttl 53, id 61858, offset 0, flags [DF], proto TCP (6), length 60)
SOURCE.53156 > DEST.7780: Flags [S], cksum 0x2b21 (correct), seq 2559114443, win 5200, options [mss 1380,nop,wscale 0,nop,nop,TS val 312 ecr 0], length 0
12:24:30.027630 IP (tos 0x0, ttl 53, id 61859, offset 0, flags [DF], proto TCP (6), length 60)
SOURCE.40667 > DEST.7780: Flags [S], cksum 0x0feb (correct), seq 3417642326, win 5200, options [mss 1380,nop,wscale 0,nop,nop,TS val 384 ecr 0], length 0

Below the relevant code of Netty server startup:

static final DefaultEventExecutorGroup e1 = new DefaultEventExecutorGroup(3);
static final EventLoopGroup bossGroup = new NioEventLoopGroup(1);
static final EventLoopGroup workerGroup = new NioEventLoopGroup();

    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup)
            .channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_BACKLOG, 100)
            .childHandler(new SocketChannelInitializer(cpds, e1, redispool))
            .childOption(ChannelOption.TCP_NODELAY, false)
            .childOption(ChannelOption.CONNECT_TIMEOUT_MILLIS,2000)
            .childOption(ChannelOption.SO_REUSEADDR, true);
    ChannelFuture future = b.bind(address);
    future.syncUninterruptibly();
    channel = future.channel();
    logger.info("Binded server to port: " + System.getProperty("port"));
    return future;

I hope somebody can give me a hint.

Update: I found out that it was a TCP problem on linux kernel, net.ipv4.tcp_tw_recycle = 0 solved my problem!

1
You should answer your own question and accept it.nllsdfx

1 Answers

0
votes

I found out that it was a TCP problem on linux kernel, net.ipv4.tcp_tw_recycle = 0 solved my problem!