diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java index fe1b94ac6e..aadb3d0711 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java @@ -74,7 +74,11 @@ public class TcpNioConnection extends AbstractTcpConnection { public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost) throws Exception { super(socketChannel.socket(), server, lookupHost); this.socketChannel = socketChannel; - this.pipedInputStream = new PipedInputStream(); + int receiveBufferSize = socketChannel.socket().getReceiveBufferSize(); + if (receiveBufferSize <= 0) { + receiveBufferSize = this.maxMessageSize; + } + this.pipedInputStream = new PipedInputStream(receiveBufferSize); this.pipedOutputStream = new PipedOutputStream(this.pipedInputStream); this.channelOutputStream = new ChannelOutputStream(); }