Hi Everyone
I am looking to call infura from behind a proxy but not able to do so. Web3 httpprovider does not allow me to use socket object received in response. Please assist
const http = require(‘http’)
const username = ‘username’
const password = ‘password’
const auth = 'Basic ’ + Buffer.from(username + ‘:’ + password).toString(‘base64’)
http.request({
host: ‘proxy.abc.com’, // IP address of proxy server
port: 8080, // port of proxy server
method: ‘CONNECT’,
path: ‘ropsten.infura.io:443’, // some destination, add 443 port for https!
// headers: {
// ‘Proxy-Authorization’: auth
// },
}).on(‘connect’, (res, socket) => {
if (res.statusCode === 200) { // connected to proxy server
// ABI code
var web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/7987556b97d54925a28b676686b67f91"));
web3.eth.defaultAccount = web3.eth.accounts[0];
var Coursetro = web3.eth.contract(ABI).at(CONTRACT_ADDRESS);
}
}
}).on(‘error’, (err) => {
console.error(‘error’, err)
}).end()