diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index fb48c471a3..7e063819b7 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -222,11 +222,11 @@ export class Connection { transactionSignatures: [], }; - url.protocol = 'ws'; + url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'; url.host = ''; url.port = String(Number(url.port) + 1); if (url.port === '1') { - url.port = '8900'; + url.port = url.protocol === 'wss:' ? '8901' : '8900'; } this._rpcWebSocket = new RpcWebSocketClient( urlFormat(url), diff --git a/web3.js/test/url.js b/web3.js/test/url.js index 1b2919afea..60b59a0ba3 100644 --- a/web3.js/test/url.js +++ b/web3.js/test/url.js @@ -3,6 +3,10 @@ /** * The connection url to use when running unit tests against a live network */ + export const url = 'http://localhost:8899/'; + +//export const url = 'https://api.testnet.solana.com/'; +//export const url = 'https://api.testnet.solana.com/'; //export const url = 'http://testnet.solana.com:8899/';