1

Just like question Connecting to blockchain on azure using web3.js and websocket, I need to use websockets to capture events.

I have gotten my http and websocket endpoints from the deployment outputs page.

The http endpoint accepts a connection, the web socket endpoint does not.

The following code works 100% on ganache but says that the http connection is good and the ws connection is bad on Azure.

const Web3 = require('web3');

async function wtf() {

    let web3http = new Web3(config.addrCurr);

    let accounthttp = web3http.eth.accounts.privateKeyToAccount('0x' + config.privateKey);

    try { await web3http.eth.getTransactionCount(accounthttp.address); console.log("http good"); } catch (e) { console.log("http error: " + e); };

    let web3ws = new Web3(config.wsCurr);

    let accountws = web3ws.eth.accounts.privateKeyToAccount('0x' + config.privateKey);

    try { await web3ws.eth.getTransactionCount(accounthttp.address); console.log("ws good"); } catch (e) { console.log("ws error: " + e); };

}

wtf();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.