I've tried to connect to my RPi 2B over wifi with both a Windows device and a Mac. Neither of these devices can see the RPi when I try to ping it. The RPi does have internet access.

I've followed some other advice on the internet to see where the connection breaks down and have run into a result that doesn't seem to have happened to others - if I ping the windows pc (or mac) from the RPi, I can get a response from them. Furthermore, for a couple minutes afterwards, the RPi can be pinged by the other devices and even remotely accessed with puTTy. But if I don't do anything for a minute or two, the connection times out. If I keep doing things to communicate with the RPi, the connection will persist. But once I let it go for a few minutes, the connection will time-out and the only way to re-establish a connection is to go to the RPi and ping one of the devices again. I'm very new to RPi and linux and the terminal in general, please go easy on me.