doc: Add a comment to clarify port selection

This commit is contained in:
Ryo Onodera 2020-10-02 13:49:27 +09:00 committed by Michael Vines
parent 9abaf6ec1d
commit 337da184f3
1 changed files with 6 additions and 0 deletions

View File

@ -1462,6 +1462,12 @@ export class Connection {
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
url.host = '';
// Only shift the port by +1 as a convention for ws(s) only if given endpoint
// is explictly specifying the endpoint port (HTTP-based RPC), assuming
// we're directly trying to connect to solana-validator's ws listening port.
// When the endpoint omits the port, we're connecting to the protocol
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
// proxy which manages WebSocket upgrade and backend port redirection.
if (url.port !== null) {
url.port = String(Number(url.port) + 1);
}