diff --git a/cmd/tendermint/commands/lite.go b/cmd/tendermint/commands/lite.go index 150371d62..bc51d7de2 100644 --- a/cmd/tendermint/commands/lite.go +++ b/cmd/tendermint/commands/lite.go @@ -26,10 +26,11 @@ just with added trust and running locally.`, } var ( - listenAddr string - nodeAddr string - chainID string - home string + listenAddr string + nodeAddr string + chainID string + home string + maxOpenConnections int cacheSize int ) @@ -38,6 +39,7 @@ func init() { LiteCmd.Flags().StringVar(&nodeAddr, "node", "tcp://localhost:26657", "Connect to a Tendermint node at this address") LiteCmd.Flags().StringVar(&chainID, "chain-id", "tendermint", "Specify the Tendermint chain ID") LiteCmd.Flags().StringVar(&home, "home-dir", ".tendermint-lite", "Specify the home directory") + LiteCmd.Flags().IntVar(&maxOpenConnections,"max-open-connections",900,"Maximum number of simultaneous connections (including WebSocket).") LiteCmd.Flags().IntVar(&cacheSize, "cache-size", 10, "Specify the memory trust store cache size") } @@ -79,7 +81,7 @@ func runProxy(cmd *cobra.Command, args []string) error { sc := proxy.SecureClient(node, cert) logger.Info("Starting proxy...") - err = proxy.StartProxy(sc, listenAddr, logger) + err = proxy.StartProxy(sc, listenAddr, logger, maxOpenConnections) if err != nil { return cmn.ErrorWrap(err, "starting proxy") } diff --git a/lite/proxy/proxy.go b/lite/proxy/proxy.go index 0294ddf68..ffd9db1d7 100644 --- a/lite/proxy/proxy.go +++ b/lite/proxy/proxy.go @@ -19,7 +19,7 @@ const ( // StartProxy will start the websocket manager on the client, // set up the rpc routes to proxy via the given client, // and start up an http/rpc server on the location given by bind (eg. :1234) -func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger) error { +func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger, maxOpenConnections int) error { err := c.Start() if err != nil { return err @@ -38,8 +38,7 @@ func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger) error core.SetLogger(logger) mux.HandleFunc(wsEndpoint, wm.WebsocketHandler) - // TODO: limit max number of open connections rpc.Config{MaxOpenConnections: X} - _, err = rpc.StartHTTPServer(listenAddr, mux, logger, rpc.Config{}) + _, err = rpc.StartHTTPServer(listenAddr, mux, logger, rpc.Config{MaxOpenConnections: maxOpenConnections}) return err }