Configuring simple server example

I am working through getting this example to work.. but not sure how to troubleshoot.

After I compile the application, I run it using the following command

./simple-server -c /Users/houst/.zssh/zssh.json -s golanghttp

Is this correct?

This is the error I receive.

Error binding service failed to initialize context: (unable to configure ziti as config environment variable ZITI_SDK_CONFIG not populated)

github.com/openziti/sdk-golang/ziti.(*contextImpl).ListenWithOptions

/Users/houst/go/pkg/mod/github.com/openziti/sdk-golang@v0.16.56/ziti/ziti.go:584

main.withZiti

/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:66

runtime.goexit

/usr/local/go/src/runtime/asm_amd64.s:1571

panic: failed to initialize context: (unable to configure ziti as config environment variable ZITI_SDK_CONFIG not populated)

goroutine 19 [running]:

main.withZiti({0x7ff7bfeff9d0, 0x2})

/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:69 +0x1ad

created by main.main

/Users/houst/DevTech/zitiapps/sdk-golang/example/simple-server/simple-server.go:86 +0x145

You need to read that code and follow it along. It's not expecting an argument to be passed that indicates the identity nor does it support flags (the -c and -s you supplied). Not all samples are uniform. This one expects you to set an environment variable named ZITI_SDK_CONFIG which represents the path to the json file.

This should work:

export ZITI_SDK_CONFIG=/Users/houst/.zssh/zssh.json
./simple-server golanghttp
1 Like

addendum: ZITI_SDK_CONFIG processing will be buried down in the golang-sdk. If the file isn’t supplied to NewContext, the sdk will look for that env variable and use the value as the path to the identity

1 Like

Awesome… this makes a lot of sense now…