Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebsocketProvider event emitter problem #2711

Closed
boomfly opened this issue Apr 19, 2019 · 1 comment · Fixed by #2855
Closed

WebsocketProvider event emitter problem #2711

boomfly opened this issue Apr 19, 2019 · 1 comment · Fixed by #2855
Labels
Bug Addressing a bug

Comments

@boomfly
Copy link

boomfly commented Apr 19, 2019

Description

WebsocketProvider.on 'connect' event stop occur after first time and does not fired after next socket connect, subscriptions not resubscribed too.

Expected behavior

provider = new Web3.providers.WebsocketProvider(wsUrl, options)
onConnect = () => console.log('connected')
provider.on('connect', onConnect)

onConnect callback should be called after each websocket reconnect

Actual behavior

onConnect called only once on first connect

Steps to reproduce the behavior

Link to example repository: https://github.com/boomfly/web3-provider-events-example

Error Logs

[Ethereum] provider "connect" event
pending tx 0xb8c7032fd7a05d7606541deec57940b6680dd52409bdb6125e6eb121dc7e4e3b
pending tx 0x8bdb5473779f7aa37e0bf2eacfa2d017280ba16166bbd24a7dfb4e80ca8b4f45
pending tx 0x0b64b3841fb115bfa25c77072d2402fd9cdb61f20eebc2561354808902a5c74e
pending tx 0x0f9defb78956072193a1fee2b53d730513f22b4ee673ff90b90e0446e3afc67d
pending tx 0x3e3e5a3407b4f38aff3b649b79ac0b57ebd49e637902f67085b3dff01c01aad0
pending tx 0x88d5ed656b1ae27eec4846cca58dff1eb2da87982d4fff5aa105d2051d214999
pending tx 0xefd02a0d9b95e91fa86f4b8ab10b8a0aef52cb43f36691a363da54ab14253b1a
pending tx 0xb347153c82b73a74b20135e3147e82bb2a04005cb1f6b639a6799bb43666ad7a

after network disable

Error while cheking connecion Error: Connection error: Timeout exceeded
Check connection connected false, isConnecting false, latestBlock undefined

Error while cheking connecion Error: Connection error: Connection is not open on send()
Check connection connected false, isConnecting false, latestBlock undefined
[Ethereum] provider "error" event { error:
_Event {
type: 'error',
isTrusted: false,
_yaeti: true,
target:
W3CWebSocket {
_listeners: [Object],
addEventListener: [Function: _addEventListener],
removeEventListener: [Function: _removeEventListener],
dispatchEvent: [Function: _dispatchEvent],
_url: 'wss://ropsten.infura.io/ws',
_readyState: 3,
_protocol: undefined,
_extensions: '',
_bufferedAmount: 0,
_binaryType: 'arraybuffer',
_connection: undefined,
_client: [WebSocketClient] },
cancelable: true,
stopImmediatePropagation: [Function] } }
Error while cheking connecion Error: Connection error: Connection is not open on send()
Check connection connected false, isConnecting false, latestBlock undefined

and enable network again onConnect not fired and subscriptions not resubscribed, but socket connected

Error while cheking connecion Error: Connection error: Connection is not open on send()
Check connection connected false, isConnecting false, latestBlock undefined
Error while cheking connecion Error: Connection error: Connection is not open on send()
Check connection connected false, isConnecting false, latestBlock undefined
Check connection connected true, isConnecting false, latestBlock 5435004
Check connection connected true, isConnecting false, latestBlock 5435005

Gists

Versions

  • web3.js: 1.0.0-beta.52
  • nodejs: 8.15.1 / 10.15.3
  • browser:
  • ethereum node: wss://ropsten.infura.io/ws or wss://mainnet.infura.io/ws
@nivida
Copy link
Contributor

nivida commented Apr 23, 2019

Thanks for opening this issue! I'll test and if required fix it asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants