Skip to content
Snippets Groups Projects
Commit 7dc1d366 authored by androlo's avatar androlo
Browse files

read/write buffer size config option for websockets

parent 6b3f4b90
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,9 @@ Tendermint officially supports only 64 bit Ubuntu.
#### Docker
`$ ./docker_build.sh` to build the image. After that, use ` $ ./docker_run.sh` to run with the default settings.
Work in progress.
`$ ./docker_build.sh` to build the image. After that, use ` $ ./docker_run.sh` to run with the default workdir (/home/.eris/.eris-db).
### Usage
......@@ -73,6 +75,8 @@ The server configuration file looks like this:
[web_socket]
websocket_endpoint= <string>
max_websocket_sessions= <number>
read_buffer_size = <number>
write_buffer_size = <number>
[logging]
console_log_level= <string>
file_log_level= <string>
......@@ -106,6 +110,8 @@ Details about the other fields and how this is implemented can be found [here](h
- `websocket_endpoint` is the name of the endpoint that is used to establish a websocket connection.
- `max_websocket_connections` is the maximum number of websocket connections that is allowed at the same time.
- `read_buffer_size` is the size of the read buffer for each socket in bytes.
- `read_buffer_size` is the size of the write buffer for each socket in bytes.
##### logging
......@@ -140,8 +146,10 @@ json_rpc_endpoint="/rpc"
[web_socket]
websocket_endpoint="/socketrpc"
max_websocket_sessions=50
read_buffer_size = 2048
write_buffer_size = 2048
[logging]
console_log_level="debug"
console_log_level="info"
file_log_level="warn"
log_file=""
```
......
......@@ -76,7 +76,12 @@ func (this *CmdProcess) Start(doneChan chan<- error) {
}
func (this *CmdProcess) Kill() error {
return this.cmd.Process.Kill()
err := this.cmd.Process.Kill()
if err != nil {
return err
}
_ , err2 := this.cmd.Process.Wait()
return err2
}
// A serve task. This wraps a running process. It was designed to run 'erisdb' processes.
......
......@@ -45,6 +45,8 @@ type (
WebSocket struct {
WebSocketEndpoint string `toml:"websocket_endpoint"`
MaxWebSocketSessions uint `toml:"max_websocket_sessions"`
ReadBufferSize uint `toml:"read_buffer_size"`
WriteBufferSize uint `toml:"write_buffer_size"`
}
Logging struct {
......@@ -59,7 +61,7 @@ func DefaultServerConfig() *ServerConfig {
kp := ""
return &ServerConfig{
Bind: Bind{
Address: "",
Address: "localhost",
Port: 1337,
},
TLS: TLS{TLS: false,
......@@ -71,6 +73,8 @@ func DefaultServerConfig() *ServerConfig {
WebSocket: WebSocket{
WebSocketEndpoint: "/socketrpc",
MaxWebSocketSessions: 50,
ReadBufferSize: 2048,
WriteBufferSize: 2048,
},
Logging: Logging{
ConsoleLogLevel: "info",
......
......@@ -69,7 +69,6 @@ func (this *ServeProcess) Start() error {
}
listenAddress := address + ":" + fmt.Sprintf("%d", port)
srv := &graceful.Server{
Server: &http.Server{
Handler: router,
......
......@@ -66,12 +66,11 @@ func (this *WebSocketServer) Start(config *ServerConfig, router *gin.Engine) {
this.config = config
this.upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
ReadBufferSize: int(config.WebSocket.ReadBufferSize),
// TODO Will this be enough for massive "get blockchain" requests?
WriteBufferSize: 1024,
WriteBufferSize: int(config.WebSocket.WriteBufferSize),
}
this.upgrader.CheckOrigin = func(r *http.Request) bool { return true }
router.GET(config.WebSocket.WebSocketEndpoint, this.handleFunc)
this.running = true
}
......
......@@ -104,6 +104,6 @@ func wsClient(doneChan chan bool, errChan chan error) {
}
client.Close()
time.Sleep(time.Millisecond * 500)
time.Sleep(time.Millisecond * 100)
doneChan <- true
}
......@@ -12,7 +12,7 @@ const SERVER_DURATION = 10
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
log15.Root().SetHandler(log15.LvlFilterHandler(
log15.LvlDebug,
log15.LvlInfo,
log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
))
gin.SetMode(gin.ReleaseMode)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment