I want to use the web3-shh functionality. I used the example from readthedocs(web3-shh). Everything works except for the subscribe operation. It raises following error:
UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the HttpProvider.
Any idea of how to deal with this? The test program I used is
import Web3 from 'web3';
const uri = process.env.ETH_NODE_URI || 'http://localhost:8545';
var web3 = new Web3(new Web3.providers.HttpProvider(uri));
var identities = [];
Promise.all([
web3.shh.newSymKey().then((id) => {identities.push(id);}),
web3.shh.newKeyPair().then((id) => {identities.push(id);})
]).then(() => {
var subscription = web3.shh.subscribe('messages', {
symKeyID: identities[0],
topics: ['0xffaadd11']
}).on('data', console.log);
}).then(() => {
web3.shh.post({
symKeyID: identities[0], // encrypts using the sym key ID
sig: identities[1], // signs the message using the keyPair ID
topic: '0xffaadd11',
payload: '0xffffffdddddd1122'
}).then(h => console.log(`Message with hash ${h} was successfuly sent`))
.catch(err => console.log("Error: ", err));
});
I would appreciate any advice on how to deal with this problem. Full examples in the documentation would be a good idea as well.