You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
992 B

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/gorilla/websocket"
  5. . "github.com/tendermint/go-common"
  6. "github.com/tendermint/go-wire"
  7. "github.com/tendermint/tendermint/rpc/client"
  8. // ctypes "github.com/tendermint/tendermint/rpc/core/types"
  9. "github.com/tendermint/tendermint/rpc/types"
  10. )
  11. func main() {
  12. ws := rpcclient.NewWSClient("ws://127.0.0.1:46657/websocket")
  13. // ws := rpcclient.NewWSClient("ws://104.236.69.128:46657/websocket")
  14. _, err := ws.Start()
  15. if err != nil {
  16. Exit(err.Error())
  17. }
  18. // Read a bunch of responses
  19. go func() {
  20. for {
  21. _, ok := <-ws.ResultsCh
  22. if !ok {
  23. break
  24. }
  25. //fmt.Println("Received response", string(wire.JSONBytes(res)))
  26. }
  27. }()
  28. // Make a bunch of requests
  29. request := rpctypes.NewRPCRequest("fakeid", "net_info", nil)
  30. for i := 0; ; i++ {
  31. reqBytes := wire.JSONBytes(request)
  32. err := ws.WriteMessage(websocket.TextMessage, reqBytes)
  33. if err != nil {
  34. Exit(err.Error())
  35. }
  36. if i%1000 == 0 {
  37. fmt.Println(i)
  38. }
  39. }
  40. ws.Stop()
  41. }