Hi All,

I am trying to add some 'protection' features to my plugin which connects to a remote websocket server, the authentication flow is that the connection is opened and the remote server waits for the authentication string to be sent. If the string is connected the connection remains open, however if the string is not accepted the websocket is closed.

I am wondering what the best way to handle this is so that if the connection gets closed, it can try again unless the connection is closed very quickly.

What I thought was that I could have a counter, which counts the number of times it has tried, and if it has tried over x times then give up, however this may not be the best way to do it as it could just try 10 times and their servers get annoyed.

The second thought I had was to have a variable for DateTimeSocketOpened which gets set to when the socket is opened, and if the socket is closed within x seconds of the variable DateTimeSocketOpened (and maybe the retries is a few) to then give up.

Is there a better way of doing this?

Many thanks!