diff --git a/cmd/dendrite-demo-pinecone/conn/client.go b/cmd/dendrite-demo-pinecone/conn/client.go index 66f9ebfa..954564d4 100644 --- a/cmd/dendrite-demo-pinecone/conn/client.go +++ b/cmd/dendrite-demo-pinecone/conn/client.go @@ -5,6 +5,7 @@ import ( "net" "net/http" "strings" + "time" "github.com/gorilla/websocket" "github.com/matrix-org/dendrite/setup" @@ -16,15 +17,24 @@ import ( func ConnectToPeer(pRouter *pineconeRouter.Router, peer string) error { var parent net.Conn + dialer := net.Dialer{ + Timeout: time.Second * 5, + KeepAlive: time.Second * 5, + } if strings.HasPrefix(peer, "ws://") || strings.HasPrefix(peer, "wss://") { - c, _, err := websocket.DefaultDialer.Dial(peer, nil) + wsdialer := websocket.Dialer{ + NetDial: dialer.Dial, + NetDialContext: dialer.DialContext, + HandshakeTimeout: time.Second * 5, + } + c, _, err := wsdialer.Dial(peer, nil) if err != nil { return fmt.Errorf("websocket.DefaultDialer.Dial: %w", err) } parent = WrapWebSocketConn(c) } else { var err error - parent, err = net.Dial("tcp", peer) + parent, err = dialer.Dial("tcp", peer) if err != nil { return fmt.Errorf("net.Dial: %w", err) } diff --git a/go.mod b/go.mod index d7f8bb4d..f41fdc39 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd github.com/matrix-org/gomatrixserverlib v0.0.0-20210302161955-6142fe3f8c2c github.com/matrix-org/naffka v0.0.0-20201009174903-d26a3b9cb161 - github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 + github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 github.com/mattn/go-sqlite3 v1.14.7-0.20210414154423-1157a4212dcb github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 diff --git a/go.sum b/go.sum index 442f38a8..e7dbe0cb 100644 --- a/go.sum +++ b/go.sum @@ -712,6 +712,8 @@ github.com/matrix-org/pinecone v0.0.0-20210518145819-76f42940e9b9 h1:foRhM2ZUQ46 github.com/matrix-org/pinecone v0.0.0-20210518145819-76f42940e9b9/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA= github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820 h1:OflgibJOmt1WvP5TxEES0i1dHj40K+pwmtQ155hZQX8= github.com/matrix-org/pinecone v0.0.0-20210518151943-2556e2cf7820/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA= +github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438 h1:pfYBf8db9X8fsieJOUZqv6Evz6YByP+n9rOTzTPC66U= +github.com/matrix-org/pinecone v0.0.0-20210524095705-54dc83854438/go.mod h1:UQzJS6UVyVwfkr+RLrdvBB1vLyECqe3fLYNcbRxv8SA= github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 h1:eCEHXWDv9Rm335MSuB49mFUK44bwZPFSDde3ORE3syk= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=