Closed etulikov closed 2 years ago
Hello :) , can you paste more info ? like all the error traceback log
Is possible that you are missing the .env
on the server ?
@Linch1 My .env
PROVIDER_WSS=wss://bsc.getblock.io/mainnet/?api_key=MY_API_CODE PROVIDER_HTTPS=https://bsc.getblock.io/mainnet/?api_key=MY_API_CODE MONGO_URL=MY_DB_CONNECTION_STRING PORT=5010 WRITE_TO_DB_SECONDS=60 FRONTEND_URL=["http://localhost:5005", "http://localhost:5003"]
Every 2-3 hours scraper failed and pm2 restart it. So sometimes it works well, but sometime right after start logs shows next error:
Detected new log undefined
Error: connection not open on send()
at Object.ConnectionError (/Users/etulikov/Projects/datameta/worker/node_modules/web3-core-helpers/lib/errors.js:66:23)
at Object.ConnectionNotOpenError (/Users/etulikov/Projects/datameta/worker/node_modules/web3-core-helpers/lib/errors.js:49:21)
at /Users/etulikov/Projects/datameta/worker/node_modules/web3-providers-ws/lib/index.js:155:37
at Map.forEach (
And then script not work. Just send this error every 1-2 minutes
[ERR UPDATING MAIN PRICE] Error: Invalid JSON RPC response: "upstream connect error or disconnect/reset before headers. reset reason: connection failure"
After errors logs looks like these
Hello, to be honest I think that is a problem with the provider you are using, on the moralis forum someone also got the same issues but they didn't give a real solution to solver this, i left here the threads
https://forum.moralis.io/t/server-error-from-the-speedy-nodes/10575
https://forum.moralis.io/t/getpastevents-bsc-error-connection-termination/10931/4
A solution could be to have a little worker that every minute count the records inside the history_transaction
model,
this one ( https://github.com/Linch1/Web3TokenCharting/blob/master/server/models/history_transactions.js )
and restart the process if the count did not change
for examlpe in pseudocode:
// import mongoose and the history_transactions model
// connect to mongodb
let initalCOunt = history_transactions.count()
while( true ){
sleep( 1minute )
let newCount = history_transactions.count()
if( intialCount == newCOunt ) { // bot has crashed
os.execute(" pm2 restart <process_id> ")
}
}
I left here the script that i'm using to achieve this
https://gist.github.com/Linch1/74ecce7711d7afe8031c01b0b3c40865
@Linch1 you mean I need lunch another worker which check transactions every minute and restart main worker if transactionsCount >= newTransactionsCount
?
Yeah fastest way to avoid this issue, i think you can just use this one
https://gist.github.com/Linch1/74ecce7711d7afe8031c01b0b3c40865
just change the line 32
Yeah fastest way to avoid this issue, i think you can just use this one
https://gist.github.com/Linch1/74ecce7711d7afe8031c01b0b3c40865
just change the line
32
Thank you very much
I have this error on my production server when run
npm run scraper
, but on local all good. Can you help?