eclipse / paho.golang

Go libraries
Other
327 stars 92 forks source link

Runtime credential change in autopaho #231

Closed swechencheng closed 7 months ago

swechencheng commented 7 months ago

Is your feature request related to a problem? Please describe. Hi, I am working on a project which the broker needs a JWT token as password for authentication. This brings the problem when I am using autopaho, which is after cm, _ = autopaho.NewConnection(ctx, cfg), it is not possible to update the cm with a new password from with a refreshed JWT, unless I actively knock off the current cm and get a new one. If my client gets disconnected passively, autopaho will never be able to reconnect since JWT is out of date and then always get disconnected with code 0x86.

Describe the solution you'd like The first thing come into my mind is that to change NewConnection() from:

func NewConnection(ctx context.Context, cfg ClientConfig) (*ConnectionManager, error)

to

func NewConnection(ctx context.Context, cfg *ClientConfig) (*ConnectionManager, error)

But I have not dig into detail to see if this is feasible.

Describe alternatives you've considered Any other ideas you may have please let me know. Thanks!

Additional context I am using v0.12.0 currently.

MattBrittan commented 7 months ago

See #109 and #127 (appear to be asking the same thing and the suggestions made there should provide you a way forward).

swechencheng commented 7 months ago

Thanks for your reply!