socketcluster-client-go
socketcluster-client-go copied to clipboard
panic: interface conversion: interface {} is nil, not map[string]interface {}
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?
this fixes the panic: https://github.com/sacOO7/socketcluster-client-go/pull/15
@stevenaldinger: how do you fix this?
@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
}
https://github.com/sacOO7/socketcluster-client-go/pull/16
Appears to be fixed in github.com/sacOO7/socketcluster-client-go v1.0.1-0.20230922063628-e06423a4ac46