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

client request lock inside if network is closed or i/o time out #5

Open
gummy789j opened this issue Mar 28, 2024 · 0 comments
Open

Comments

@gummy789j
Copy link

gummy789j commented Mar 28, 2024

The following experiment would be lock at client.Request because network is closed or i/o time out, can you export a method to check the network is closed or not to avoid lock at client.Request.

	config := xrpl.ClientConfig{
		URL: "wss://s.altnet.rippletest.net:51233/",
	}
	client := xrpl.NewClient(config)
	err := client.Ping([]byte("PING"))
	if err != nil {
		panic(err)
	}

        // test send request after close
       r.Close()
	
	resp, err := client.Request(xrpl.BaseRequest{
		"id":           "example_ledger_req",
		"command":      "ledger",
		"ledger_index": "validated",
		"transactions": false,
		"expand":       false,
		"owner_funds":  false,
	})
	if err != nil {
		panic(err)
	}

	var ok bool
	index, ok = (resp["result"].(map[string]interface{})["ledger_index"]).(float64)
	if !ok {
		fmt.Printf("ledger_index reflect failed: %T", index)
	}
	

another experiment is close twice, and it would be lock at second close, so we need a way to know the connection is close or not or just skip.

	config := xrpl.ClientConfig{
		URL: "wss://s.altnet.rippletest.net:51233/",
	}
	client := xrpl.NewClient(config)
	err := client.Ping([]byte("PING"))
	if err != nil {
		panic(err)
	}

        // 1st
       r.Close()
       
       // 2nd
       r.Close() // will be lock in this close
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

1 participant