-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproviderWs.js
38 lines (31 loc) · 1.06 KB
/
providerWs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const Web3 = require( 'web3' )
require('dotenv').config()
const WS_PROVIDER_LINK = process.env.ETHERUM_MAIN_LINK
// const WS_PROVIDER_LINK = process.env.ARBITRUM_MAIN_LINK//arbitrum-one node end-point
const optionsWs = {
timeout: 30000, // ms
// Useful for credentialed urls, e.g: ws://username:password@localhost:8546
// headers: {
// authorization: 'Basic username:password'
// },
clientConfig: {
// Useful if requests are large
maxReceivedFrameSize: 100000000, // bytes - default: 1MiB
maxReceivedMessageSize: 100000000, // bytes - default: 8MiB
// Useful to keep a connection alive
keepalive: true,
keepaliveInterval: 60000 // ms
},
// Enable auto reconnection
reconnect: {
auto: true,
delay: 5000, // ms
maxAttempts: 5,
onTimeout: false
}
};
// const web3Ws = new Web3(new Web3.providers.HttpProvider(HTTP_PROVIDER_LINK, optionsWs))
const web3Ws = new Web3(new Web3.providers.WebsocketProvider(WS_PROVIDER_LINK, optionsWs))
module.exports = {
web3Ws
}