Skip to content

Commit

Permalink
Specify frame size and update dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Feb 21, 2017
1 parent cd4e7d0 commit 0d3d1ac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions api/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const pingTimeout = 30 * time.Second
// modelRoot is the prefix that all model API paths begin with.
const modelRoot = "/model/"

// Use a 64k frame size for the websockets while we need to deal
// with x/net/websocket connections that don't deal with recieving
// fragmented messages.
const websocketFrameSize = 65536

var logger = loggo.GetLogger("juju.api")

type rpcConnection interface {
Expand Down Expand Up @@ -359,6 +364,10 @@ func (st *state) connectStream(path string, attrs url.Values, extraHeaders http.
dialer := &websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: st.tlsConfig,
// In order to deal with the remote side not handling message
// fragmentation, we default to largeish frames.
ReadBufferSize: websocketFrameSize,
WriteBufferSize: websocketFrameSize,
}
var requestHeader http.Header
if st.tag != "" {
Expand Down Expand Up @@ -540,6 +549,10 @@ func dialAPI(info *Info, opts DialOpts) (*dialResult, error) {
&websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
// In order to deal with the remote side not handling message
// fragmentation, we default to largeish frames.
ReadBufferSize: websocketFrameSize,
WriteBufferSize: websocketFrameSize,
},
}
opts.DialWebsocket = dialer.Dial
Expand Down
9 changes: 9 additions & 0 deletions apiserver/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import (
"github.com/juju/juju/apiserver/params"
)

// Use a 64k frame size for the websockets while we need to deal
// with x/net/websocket connections that don't deal with recieving
// fragmented messages.
const websocketFrameSize = 65536

var websocketUpgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool { return true },
// In order to deal with the remote side not handling message
// fragmentation, we default to largeish frames.
ReadBufferSize: websocketFrameSize,
WriteBufferSize: websocketFrameSize,
}

func websocketServer(w http.ResponseWriter, req *http.Request, handler func(ws *websocket.Conn)) {
Expand Down
2 changes: 1 addition & 1 deletion dependencies.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ github.com/godbus/dbus git 32c6cc29c14570de4cf6d7e7737d68fb2d01ad15 2016-05-06T2
github.com/golang/protobuf git 34a5f244f1c01cdfee8e60324258cfbb97a42aec 2015-05-26T01:21:09Z
github.com/google/go-querystring git 9235644dd9e52eeae6fa48efd539fdc351a0af53 2016-04-01T23:30:42Z
github.com/gorilla/schema git 08023a0215e7fc27a9aecd8b8c50913c40019478 2016-04-26T23:15:12Z
github.com/gorilla/websocket git 13e4d0621caa4d77fd9aa470ef6d7ab63d1a5e41 2015-09-23T22:29:30Z
github.com/gorilla/websocket git 804cb600d06b10672f2fbc0a336a7bee507a428e 2017-02-14T17:41:18Z
github.com/gosuri/uitable git 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 2016-04-04T20:39:58Z
github.com/joyent/gocommon git ade826b8b54e81a779ccb29d358a45ba24b7809c 2016-03-20T19:31:33Z
github.com/joyent/gosdc git 2f11feadd2d9891e92296a1077c3e2e56939547d 2014-05-24T00:08:15Z
Expand Down
2 changes: 0 additions & 2 deletions rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ func (conn *Conn) input() {
close(conn.dead)
}

var errRemoteClosed = errors.New("remote closed connection")

// loop implements the looping part of Conn.input.
func (conn *Conn) loop() error {
for {
Expand Down

0 comments on commit 0d3d1ac

Please sign in to comment.