'no close frame received or sent' issue

For now I am recursively calling the same function in exception block to automatically reconnect on the said exception. This is not ideal