centrifugal / centrifuge

Real-time messaging library for Go. The simplest way to add feature-rich and scalable WebSocket support to your application. The core of Centrifugo server.

Home Page:https://pkg.go.dev/github.com/centrifugal/centrifuge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem to build library centrifuge

beho1der opened this issue · comments

I install library:

$ go get github.com/centrifugal/centrifuge

get error:

../github.com/centrifugal/centrifuge/handler_sockjs.go:129:13: wsUpgrader.WriteBufferPool undefined (type *websocket.Upgrader has no field or method WriteBufferPool)
../github.com/centrifugal/centrifuge/handler_websocket.go:229:10: upgrade.WriteBufferPool undefined (type *websocket.Upgrader has no field or method WriteBufferPool)

@beho1der hello.

If you look at Centrifuge dependency Gorilla WebSocket - you will see that it has WriteBufferPool in Upgrader struct. So looks like you have an old version of Gorilla WebSocket (I suppose you work with GOPATH ?).

So try to update Gorilla WebSocket:

go get -u github.com/gorilla/websocket

Then run:

go get -u github.com/centrifugal/centrifuge

If this does not help then please provide full information: Go version, directory layout, describe how you work with dependencies in general.

In general with recent Go version and go modules all you need to do is:

mkdir test
cd test
go mod init myproject
go get github.com/centrifugal/centrifuge

Realy github.com/gorilla/websocket, i update and all work

Great, take a note that this library has no v1 release, and API is still evolving, so if you decide to use it - use it with strict versioning. For example, there are #163 and #167 pull requests that will change the current API a bit after merging and releasing a new version.