Calling ropsten.infura.io behind a proxy

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()

Hi, could you also provide the error you are receiving?

Hi Mike

I am getting not able to connect to ropsten.infura.io

we get the following error “Invalid JSON RPC response: undefined”.

If you observe , as we are behind an enterprise firewall , they have blocked ropsten.infura.io but can connect to it after a proxy server call and authentication.

I am not sure we3.provider.Httpprovider will identify that a proxy call has been made and socket object is availabe

Unfortunately we do not support this configuration when sending requests. We will keep you updated if this changes.