update server to nonblocking and add exception catch