[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration

Open Beginner friendly
#11,515 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@amalsaidov is already working on this.

Since Nov 12, 2026.

  • #11516 by @amalsaidov — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
networking

Research direction

Read RemotingHelper.connect(SocketAddress, int) and compare its buffer configuration with NettyRemotingClient and NettyRemotingServer. Check the existing tests for RemotingHelper and add coverage using distinct send and receive buffer settings; done when each setting maps to its matching socket option.

Written by the indexing model from the issue text.

Description

Before Creating the Bug Report
Runtime platform environment

All platforms.

RocketMQ version

develop branch (current), present in released versions as well.

Describe the Bug

RemotingHelper.connect(SocketAddress, int) applies the configured socket buffer sizes to the wrong socket options. The send-buffer knob (NettySystemConfig.socketSndbufSize) is used to set the receive buffer, and the receive-buffer knob (NettySystemConfig.socketRcvbufSize) is used to set the send buffer:

if (NettySystemConfig.socketSndbufSize > 0) {
    sc.socket().setReceiveBufferSize(NettySystemConfig.socketSndbufSize);
}
if (NettySystemConfig.socketRcvbufSize > 0) {
    sc.socket().setSendBufferSize(NettySystemConfig.socketRcvbufSize);
}

Everywhere else in the remoting module the mapping is the opposite one, e.g. in NettyRemotingClient and NettyRemotingServer:

  • socketSndbufSize -> SO_SNDBUF (send buffer)
  • socketRcvbufSize -> SO_RCVBUF (receive buffer)

So in connect() the two are swapped.

This method is used by the store HA replication clients (DefaultHAClient and AutoSwitchHAClient). When an operator tunes com.rocketmq.remoting.socket.sndbuf.size / com.rocketmq.remoting.socket.rcvbuf.size, the HA sockets end up with the send and receive buffer sizes exchanged, which works against the intended replication tuning (the receive-heavy slave side and send-heavy master side get the opposite buffer they were configured for).

Expected Behavior

connect() should set SO_SNDBUF from socketSndbufSize and SO_RCVBUF from socketRcvbufSize, consistent with the rest of the remoting code.

Steps to Reproduce

Configure distinct values for the two knobs and open a connection through RemotingHelper.connect, then read back Socket#getSendBufferSize() / Socket#getReceiveBufferSize(): the reported send buffer tracks the receive-buffer configuration and vice versa.

How To Reproduce (code)

Open two connections that differ only in socketSndbufSize; the connection configured with the smaller send buffer ends up with the larger send buffer, because the value is taken from socketRcvbufSize.

Dominant language
Java
Stars
22.7k
Forks
12k
Avg merge
3d 18h
Merged PRs (30d)
17

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/rocketmq

All issues in apache/rocketmq

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.