Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Connections number and subscribing to events #5

Open
wnz99 opened this issue Oct 23, 2017 · 1 comment
Open

Connections number and subscribing to events #5

wnz99 opened this issue Oct 23, 2017 · 1 comment

Comments

@wnz99
Copy link

wnz99 commented Oct 23, 2017

Apologies it this is not the right place to ask, but I have looked at the available documentation and could not figure out myself. I am also new to js programming.

I have two questions.

  1. Once the api is initiated with:
const transport = new Api.Provider.Http(HttpsUrl, timeout);
const api = new Api(transport);

the browser stars doing http JSON POST requests to my remote RPC Parity server to the method net_listening every timeout seconds. Which is the correct way to destroy api to stop this polling?

  1. Upon subscription to an event, such as:

api.subscribe('eth_blockNumber', this.onNewBlockNumber)

the browser starts to send POST requests every second.
Upon unsubscription:

api.unsubscribe(subscriptionID)

these requests keep going on. Is this an expected behaviour? I am unsubscribing to events when unmounting react components. Ideally I would like the api to stop doing those requests in order to minimize the load and bandwidth on the Parity node.

Thank you for any help

@jacogr
Copy link
Contributor

jacogr commented Oct 30, 2017

Yes, this is a big of a known issue - in the case of HTTP there is no way to determine that the node is still alive. This method for checking is horrible to say the least (also implemented the same way in other non-Parity libs). Could certainly take a re-look specifically for HTTP, possibly tracking the last call.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants