Skip to content

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

Open
@gummy789j

Description

@gummy789j

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions