@admin I think there is some issue with the __on_close function which was causing this error. In the function definition I added 2 additional arguments a and b as shown below. This fixed the error I was getting while closing the connection using ss.ws.close().
23474fa1-a05c-47fe-ac62-49d07f52c2a9-image.png
Kindly look into it.