failed to use global session when cached socket is closed
levimm opened this issue · comments
I'm using this mongo adapter for a while and sometimes when network is reconnect, I got "Closed explicitly" error.
After digging in, I find this adapter using the global session to do all the operation. When the cache socket is closed, it won't restore the session.
I'd like to create a pr to fix this issue. There're two solutions. First continues using this global session but checks session status in a goroutine to refresh it. Second uses session.Copy() for all db operation. Not sure which one is better. Any advise?
Hi @levimm , why not rebuild the connection if the socket is closed? I mean if the socket is found closed, there would be an error, then we reconnect to get the session back. I think this way works the best?
Merged.
@tokingHong In that issue (casbin/casbin#191), I asked about a minimized working example, not still not provided yet.
This issue can be closed now.