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

panic: interface conversion: interface {} is nil, not map[string]interface {} #14

Open
stevenaldinger opened this issue Mar 6, 2021 · 5 comments

Comments

@stevenaldinger
Copy link

This happens a few seconds after successfully connecting to the server when I run the code in the README. No message is being published and there's nothing but a fmt.Println in my startCode function.

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 37 [running]:
github.com/sacOO7/socketcluster-client-go/scclient/parser.GetMessageDetails(0x0, 0x0, 0x0, 0x6d7d40, 0xc000058ef0, 0x7cc220, 0xc00000e480, 0x9870b4, 0x9870b4, 0xf4c)
	/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/parser/parser.go:28 +0x40e
github.com/sacOO7/socketcluster-client-go/scclient.(*Client).registerCallbacks.func3(0x0, 0x0, 0xc0001ac000, 0xc000106080, 0x76b0e9, 0x26, 0x100, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/sac!o!o7/[email protected]/scclient/client.go:65 +0x188
github.com/sacOO7/gowebsocket.(*Socket).Connect.func4(0xc000108020)
	/go/pkg/mod/github.com/sac!o!o7/[email protected]/gowebsocket.go:154 +0x264
created by github.com/sacOO7/gowebsocket.(*Socket).Connect
	/go/pkg/mod/github.com/sac!o!o7/[email protected]/gowebsocket.go:133 +0x50c

Is this client maintained/expected to work with the latest socketcluster server release?

@stevenaldinger
Copy link
Author

stevenaldinger commented Mar 7, 2021

this fixes the panic: #15

@gobliggg
Copy link

gobliggg commented Aug 8, 2021

@stevenaldinger: how do you fix this?

@stevenaldinger
Copy link
Author

@gobliggg in scclient/parser/parser.go line 28: https://github.com/sacOO7/socketcluster-client-go/blob/master/scclient/parser/parser.go#L28

replace:

	itemsMap := message.(map[string]interface{})

with a check that the conversion is successful. keep in mind there's likely some deeper rooted issue that the conversion failed to begin with, but its still important to be catching errors like this. I'm not sure what appropriate error handling should be happening here, this just completely ignores the error instead of letting it panic:

	itemsMap, ok := message.(map[string]interface{})
	if !ok {
		return
	}

@happilymarrieddad
Copy link

#16

@happilymarrieddad
Copy link

Appears to be fixed in github.com/sacOO7/socketcluster-client-go v1.0.1-0.20230922063628-e06423a4ac46

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

3 participants