Add retry mechanism when finding session sockets to handle race
conditions. The function now makes up to 3 attempts with 500ms delays
before failing, which should improve reliability when sessions are
connecting or reconnecting.
Also includes code style reformatting for consistency.
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>