Fix error in client and add ip detection in server