pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: james-johnston-thumbtack (@james-johnston-thumbtack) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3481: Support TCP receive window greater than 64K
Date: Thu, 16 Jan 2025 10:59:22 +0000
Message-ID: <[email protected]> (raw)

The driver offers an option `receiveBufferSize` which sets the `SO_RCVBUF` option via the [setReceiveBufferSize](https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html#setReceiveBufferSize-int-) function.

This takes place in the following code chunk:

https://github.com/pgjdbc/pgjdbc/blob/032d0e225a91e866d7dae680ebb784507392e803/pgjdbc/src/main/java/...

However, I note that the call to `setReceiveBufferSize` on line 169 takes place _after_ the `PGStream` connector has already [connected to the PG host](https://github.com/pgjdbc/pgjdbc/blob/032d0e225a91e866d7dae680ebb784507392e803/pgjdbc/src/main/java/...) on line 140.

This carries with it an unfortunate limitation, according to the [setReceiveBufferSize documentation](https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html#setReceiveBufferSize-int-):

> The value of [SO_RCVBUF](https://docs.oracle.com/javase/8/docs/api/java/net/SocketOptions.html#SO_RCVBUF) is also used to set the TCP receive window that is advertized to the remote peer. Generally, the window size can be modified at any time when a socket is connected. However, if a receive window larger than 64K is required then this must be requested before the socket is connected to the remote peer. There are two cases to be aware of:
> 
> ...
> 2.  For client sockets, setReceiveBufferSize() must be called before connecting the socket to its remote peer.

This limitation seems to be confirmed in [section 2.1 in RFC-1323](https://datatracker.ietf.org/doc/html/rfc1323#section-2).

Therefore, would it make sense to move the call to `setReceiveBufferSize` to be _before_ the connection is made, so that the TCP receive window > 64K can be correctly set?

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3481: Support TCP receive window greater than 64K
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox