Update client.py

Handle communication exceptions.