From 50f110070be321d1df8f03b2544ca621f7c3fe21 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 28 Oct 2020 17:11:00 -0400 Subject: [PATCH] add section for websocket event listener (#5619) ### Description a small section explaining how to set up a smart contract event listener using web3js and forno --- packages/docs/developer-resources/forno/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/docs/developer-resources/forno/README.md b/packages/docs/developer-resources/forno/README.md index 9c03bed9da6..df16bda69af 100644 --- a/packages/docs/developer-resources/forno/README.md +++ b/packages/docs/developer-resources/forno/README.md @@ -24,3 +24,7 @@ Baklava = 'https://baklava-forno.celo-testnet.org' Mainnet = 'https://forno.celo.org' or 'wss://forno.celo.org/ws' (for websocket support) ``` + +### Websocket connections & Event listeners + +Websocket connections are useful for listening to logs (aka events) emitted by a smart contract, but Forno only allows a websocket connection for 20 minutes before disconnecting. On disconnect, you can reconnect to the websocket endpoint to keep listening. [Here](https://gist.github.com/critesjosh/a230e7b2eb54c8d330ca57db1f6239db) is an example script of how to set up an event listener that reconnects when the connection is broken.