final rev, added a try catch to avoid crashes on ws.send()