Back to All

alchemy.ws.on does not receive more transactions after a couple of hours

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