GoLang API Connect stuck

FalkLademann
FalkLademann Member Posts: 8
edited November 2022 in General Discussions #1

Doing an err = messagingService.Connect()

leads me into dead end, client application is stuck forever, blocking any further execution.

Is there something I can check on what's wrong?

I can actually see my client is connected, telling from the web admin, having a subscription.

But client application won't proceed any further from this point onward.

In addition, I tried with a wrong password, in which case no client is shown in the Admin, but the application is again stuck at messagingService.Connect() here as well (no error message given).


Using:

go version go1.19.3 darwin/amd64

solace.dev/go/messaging v1.1.0

Broker Version 10.1.1.32 running in

Docker Engine: 20.10.21

Tagged:

Answers

  • mcardy
    mcardy Member, Employee Posts: 12 Solace Employee

    Hey FalkLademann, thanks for checking out the Go API! One thing you can try to see more information about why the client might be hanging is to enable debug logs: https://pkg.go.dev/solace.dev/go/messaging@v1.1.0/pkg/solace/logging#SetLogLevel. This should show us where the API is stuck.

    Can you also post a snippet of the setup and connect code you are using (redacting any internal information of course)?

  • FalkLademann
    FalkLademann Member Posts: 8
    edited November 2022 #3

    Identified the cause of the issue:

    My code is pretty standard, taken from the examples you provide. Only difference is, I've placed my broker connect code into func init() , as I'm initializing a database access in the init() part as well.

    Works perfectly fine with Postgres, it seems not to work with the Solace client, however.

    Moving this exact same Solace code section into func main() solved the issue. I believe it was not a very wrong thinking, to locate it into the func init() initially, but apparently the Go environment is not ready enough for Solace at this stage.

    If you put the code into init() , one should be able to reproduce (and debug) the root of the issue.

  • mcardy
    mcardy Member, Employee Posts: 12 Solace Employee

    Interesting! I'll have to try that out and see what happens when connecting the API in init. Thanks for reporting your findings, glad you got it solved.