The correct way to handle session expire is to create a new session and should handle by the client instead of the library.

Could you explain why you want to retry here?