Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime Error: Invalid memory address or nil pointer dereference #7

Closed
mxzinke opened this issue Dec 21, 2019 · 0 comments
Closed

Runtime Error: Invalid memory address or nil pointer dereference #7

mxzinke opened this issue Dec 21, 2019 · 0 comments

Comments

@mxzinke
Copy link

mxzinke commented Dec 21, 2019

Hey Guys,

just bumped into this websocket topic and tried out this pkg for connecting to an open API. Maybe I am doing something wrong

Bildschirmfoto 2019-12-21 um 13 08 12

Go Version: go1.13.5 darwin/amd64 (at Mac)

My Code:

func (api BrokerAPI) setupUpdateStream() {
	type authData struct {
		KeyID     string `json:"key_id"`
		SecretKey string `json:"secret_key"`
	}
	type streamAuthAction struct {
		Action string      `json:"action"`
		Data   interface{} `json:"data"`
	}

	streamURL := fmt.Sprintf("ws://%s/%s/%s", api.URL, apiVersion, streamEndpoint)

	socket := gowebsocket.New(streamURL)
	socket.Connect()

	streamAuthData := streamAuthAction{Action: "authenticate", Data: authData{KeyID: api.Key, SecretKey: api.Secret}}
	parsedAuthData, authErr := json.Marshal(streamAuthData)
	if authErr != nil {
		log.Fatalf("Authentication failed, because stream messages: %s", authErr)
	}

	socket.SendBinary(parsedAuthData)

	...
}
@mxzinke mxzinke closed this as completed Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant