nanmu42 / etherscan-api

:guitar: Golang client for Ethereum Etherscan API (and its families like BscScan) / Golang 以太坊 Etherscan API库(也支持同一家族的BscScan)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wsarecv error

zhzblackc12 opened this issue · comments

Code:
client := etherscan.NewCustomized(etherscan.Customization{
Timeout: 15 * time.Second,
Key: "2N9DPZFRMK2B9MNK17JX******", // my bscscan api key
BaseURL: "https://api.bscscan.com/api?",
Verbose: false,
})

// (optional) add hooks, e.g. for rate limit
client.BeforeRequest = func(module, action string, param map[string]interface{}) error {
	return nil
}

client.AfterRequest = func(module, action string, param map[string]interface{}, outcome interface{}, requestErr error) {
	// ...
}

// check account balance
balance, err := client.AccountBalance("0xb84c69a8e7b9d26ea1efd91fd99ff6d297aca415")
if err != nil {
	panic(err)
}
// balance in wei, in *big.Int type
fmt.Println(balance.Int())

Result: read tcp 192.168.31.24:59215->23.92.68.154:443: wsarecv: 远程主机强迫关闭了一个现有的连接。

Maybe you can set Verbose to true and see what's happening behind the scenie.

Maybe you can set Verbose to true and see what's happening behind the scenie.

Could u tell me where to set?

Code:
client := etherscan.NewCustomized(etherscan.Customization{
Timeout: 15 * time.Second,
Key: "2N9DPZFRMK2B9MNK17JX******", // my bscscan api key
BaseURL: "https://api.bscscan.com/api?",
Verbose: false, ← HERE
}

API server listening at: 127.0.0.1:50239

GET /api?action=balance&address=0xb84c69a8e7b9d26ea1efd91fd99ff6d297aca415&apikey=2N9DPZFRMK2B9MNK17JX***&module=account&tag=latest HTTP/1.1
Host: api.bscscan.com
User-Agent: etherscan-api(Go)
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip

[Error] sending request: Get "https://api.bscscan.com/api?action=balance&address=0xb84c69a8e7b9d26ea1efd91fd99ff6d297aca415&apikey=2N9DPZFRMK2B9MNK17JX5ZQ4KEJWTIG8Z3&module=account&tag=latest": read tcp 192.168.31.24:50244->2
3.92.68.154:443: wsarecv

Is the connection between the client and API reliable?

I suppose the problem is caused by the remote, instead of the side of the package.

To be certain on this, you may use the package to call Etherscan's API, using the same system and environment.

tks! Cause my netowrk in proxy mode

You are welcome.