Go plugin build error with protobuf

Using minimal example
Using DockerBuild in Windowsx64
Builded using these commands:
*PS C:\Users\Administrator\plugin_code> go get -u “github.com/heroiclabs/nakama-common” *

  • PS C:\Users\Administrator\plugin_code> docker run --rm -w “/builder” -v “${PWD}:/builder” heroiclabs/nakama-pluginbuilder:2.11.1 build -buildmode=plugin -trimpath -o ./modules/plugin_code.so*
  • go: downloading heroiclabs/nakama-common v1.4.0*
  • go: downloading protobuf v1.3.4*


nakama | {“level”:“fatal”,“ts”:“2020-04-12T06:12:13.539Z”,“msg”:“Failed initializing runtime modules”,“error”:“plugin.Open(”/nakama/data/modules/plugin_code”): plugin was built with a different version of package github.com/golang/protobuf/proto",“stacktrace”:"main.main\n\tmain.go:132\nruntime.main\n\truntime/proc.go:203"}

Nakama version : 2.11.1
i had to remove github site from some errors because forums doesnt allow me to post links.

@irajsb The Nakama v2.11.1 release requires the protobuf v1.3.5 release. You can setup your dependencies to match like so:

env GO111MODULE=on go get "github.com/heroiclabs/nakama-common@v1.4.0"
env GO111MODULE=on go get "github.com/golang/protobuf@v1.3.5"
env GO111MODULE=on go mod edit -replace "github.com/golang/protobuf=github.com/golang/protobuf@v1.3.5"

Please try that and let me know if it resolves your issue. Your mod file should look somewhat like:

module games/project

go 1.14

require (
	github.com/golang/protobuf v1.3.5 // indirect
	github.com/heroiclabs/nakama-common v1.4.0

replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.5

The replace is used to force the version if another dependency you use tries to specify a different transitive version.

Worked like a charm !!thanks!

1 Like

Didnt want to create another thread for this : is it possible to get client ip addres from a request with signature like this :
func RegisterServer(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, payload string) (string, error)

This is not related to the current topic, so it should have been a new thread.

Have a look at the documentation for fields available in the context here, one of them is the caller’s IP address.

I think @zyro is right but this is some quick code to show what you need in Go.

clientIP, ok := ctx.Value(runtime.RUNTIME_CTX_CLIENT_IP).(string)
if !ok {
    // handle error