Hey, this does seem like an connection issue, i would attempt to restart your wifi router, and try again. Connection issues on WIFI can be due to the amount of connected devices on said one wifi network. also be sure you are on the latest version mcpe has to offer, and double check the server version is matching your current minecraft version. Also, you mentioned madcommands, delete it. this may be your major issue.