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

API can not work any more #244

Open
benhaben opened this issue Sep 2, 2024 · 2 comments
Open

API can not work any more #244

benhaben opened this issue Sep 2, 2024 · 2 comments

Comments

@benhaben
Copy link

benhaben commented Sep 2, 2024

package main

import (
	"log"
	"time"

	"context"
	"fmt"

	"github.com/gagliardetto/solana-go/rpc"
	"golang.org/x/time/rate"
)

func main() {
	cluster := rpc.MainNetBeta

	rpcClient := rpc.NewWithCustomRPCClient(rpc.NewWithLimiter(
		cluster.RPC,
		rate.Every(time.Second), // time frame
		5,                       // limit of requests per time frame
	))

	// Get the recent blockhash:

	recent, err := rpcClient.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)
	if err != nil {
		log.Fatalf("Failed to get latest blockhash: %v", err)
	}

	fmt.Printf("  Blockhash: %s\n", recent.Value.Blockhash)
	fmt.Printf("  LastValidBlockHeight: %d\n", recent.Value.LastValidBlockHeight)
}

report error : Failed to get latest blockhash: rpc call getLatestBlockhash() on https://api.mainnet-beta.solana.com: Post "https://api.mainnet-beta.solana.com": read tcp 127.0.0.1:60388->127.0.0.1:33210: read: connection reset by peer

@HyperMutekiXXX
Copy link

same problem. did u solve it?

@gagliardetto
Copy link
Owner

Maybe your IP got blocked? It's public RPC.

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

No branches or pull requests

3 participants