Discussions
alchemy.ws.on does not receive more transactions after a couple of hours
about 1 month ago by Hugo Mag
Hi there,
I've been using Alchemy to listen to events on a specific contract but after a couple of hours it dies and I don't see a way to at least be some kind of error or warning so I can reconnect.
The code I'm using is the following:
alchemy.ws.on(
{
method: AlchemySubscription.PENDING_TRANSACTIONS, // "alchemy_pendingTransactions",
toAddress: contractAddress
},
(res) => {
});
Is there any way to do this?
For instance, something like when we connect to the mempool through a node:
const customWsProvider = new ethers.providers.WebSocketProvider(nodeUrl);
customWsProvider._websocket.on("close", async (code) => {
});
Thanks.
Best regards,
Hugo
Start typing markdown or type / to insert a block