From 3a1c582df540bda8eacdbb38cf316b90aab655f5 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 13 Apr 2020 17:42:33 -0700 Subject: [PATCH] fix: connection url can upgrade to a websocket if no port is supplied --- web3.js/src/connection.js | 5 ++--- web3.js/test/url.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index df018f6971..fe4a36c721 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -806,9 +806,8 @@ export class Connection { url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'; url.host = ''; - url.port = String(Number(url.port) + 1); - if (url.port === '1') { - url.port = url.protocol === 'wss:' ? '8901' : '8900'; + if (url.port !== null) { + url.port = String(Number(url.port) + 1); } this._rpcWebSocket = new RpcWebSocketClient(urlFormat(url), { autoconnect: false, diff --git a/web3.js/test/url.js b/web3.js/test/url.js index 433b5cf61b..3a3f4bb941 100644 --- a/web3.js/test/url.js +++ b/web3.js/test/url.js @@ -6,5 +6,5 @@ export const url = 'http://localhost:8899/'; -//export const url = 'https://devnet.solana.com:8443/'; -//export const url = 'http://devnet.solana.com:8899/'; +//export const url = 'https://devnet.solana.com/'; +//export const url = 'http://devnet.solana.com/';