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

Add Bug Title Here #4425

Closed
X1aZhongwen opened this issue Oct 16, 2023 · 2 comments
Closed

Add Bug Title Here #4425

X1aZhongwen opened this issue Oct 16, 2023 · 2 comments
Assignees
Labels
v5 Issues regarding legacy-v5

Comments

@X1aZhongwen
Copy link

Ethers Version

5

Search Terms

utf8

Describe the Problem

Error: invalid response - 0
at request.onreadystatechange (d:\设计网页\node_modules\ethers\utils\web.js:84:29)
at exports.XMLHttpRequest.dispatchEvent (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:591:25)
at setState (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:610:14)
at exports.XMLHttpRequest.handleError (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:532:5)
at ClientRequest.errorHandler (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:459:14)
at ClientRequest.emit (node:events:517:28)
at TLSSocket.socketErrorListener (node:_http_client:501:9)
at TLSSocket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3) {
statusCode: 0,
responseText: 'Error: read ECONNRESET\n' +
' at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)'
}

Node.js v18.18.1

Code Snippet

import {ethers} from "ethers"// ts ES6

const Mainnet_RPC = 'https://eth-mainnet.g.alchemy.com/v2/Sp3-m00XFKs2Bs7LC8MyGn4Cx94CpIwl';
const Sophie_RPC = 'https://eth-sepolia.g.alchemy.com/v2/3uvxjzVO19PqwZSiiprJ7nCa2vm0zDlc';

const provider = new ethers.providers.JsonRpcProvider(Mainnet_RPC);
const Testprovider = new ethers.providers.JsonRpcProvider(Sophie_RPC);


const main = async () => {
    const balance = await provider.getBalance(`ethers.eth`);
    console.log(`ETH Balance of vitalik: ${ethers.utils.formatEther(balance)} ETH`);
    const blockNumber = await provider.getBlockNumber();
    console.log(`now the blockchain high is :`, blockNumber)
// ethers.utils.parseEther("1.0") { BigNumber: "1000000000000000000" }
}
main()

Contract ABI

No response

Errors

Error: invalid response - 0
    at request.onreadystatechange (d:\设计网页\node_modules\ethers\utils\web.js:84:29)
    at exports.XMLHttpRequest.dispatchEvent (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:591:25)
    at setState (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (d:\设计网页\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:459:14)
    at ClientRequest.emit (node:events:517:28)
    at TLSSocket.socketErrorListener (node:_http_client:501:9)
    at TLSSocket.emit (node:events:517:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3) {
  statusCode: 0,
  responseText: 'Error: read ECONNRESET\n' +
    '    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)'
}

Node.js v18.18.1

Environment

node.js (v12 or newer)

Environment (Other)

No response

@X1aZhongwen X1aZhongwen added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Oct 16, 2023
@ricmoo
Copy link
Member

ricmoo commented Nov 1, 2023

This error generally indicates a server SSL error. It could be a proxy was messing up the SSL/TLS data, the certificate could have been expired, the server could have been throttling you, etc.

There isn't much Ethers can do to resolve this directly, but it is strange that the error response looks like that of a WebSocket, but you are using the HTTP-based Providers. Can you provide more context as to what you were doing, the network situation, etc?

@ricmoo ricmoo removed the investigate Under investigation and may be a bug. label Feb 22, 2024
@ricmoo
Copy link
Member

ricmoo commented Feb 22, 2024

Closing this as I don't believe it to be an issue with Ethers. But please re-open if you have additional information to add.

Thanks! :)

@ricmoo ricmoo closed this as completed Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants