Internet disconnects on Rasperry Pi 2 after period of inactivity

This is the situation:-
I have the OSMC installed in my Raspberry Pi 2 and have connected to internet via Ethernet. The Pi is hardwired directly to my router. As such OSMC runs excellent.

The only issue comes in when i leave the Raspberry Pi 2 inactive, it looks like after a period of inactivity the internet connection gets disconnected. I am not sure what is causing this problem or how to fix it. I would really appreciate your help in fixing this.

Please note that, i have also connected my USB keyboard K400 to Raspberry Pi 2. This probably is not related to a bad power supply since i use the official one from Canakit [5V 2.5A power adapter]. I also do not see the rainbow color box or anything of that sort which would indicate power issues.

Try setting a static IP address temporarily to see if it’s a DHCP issue.

Sam

Sam, I always had a static IP for my Pi… Is there anything else which I have to tweak?

Would be useful to see some logs after the connection drops. You can run dmesg to grab it manually. Also see if you can get ifconfig

Sam, I am not sure if i can SSH into my Pi when the connection drops to run dmesg or ifconfig command. Do i need to restart my Pi after the connection drops and then run the commands you mentioned?

You can connect a keyboard and use console.

I am curious about this as well, as this happens to me, too which further leads me to believe it’s something with the osmc or raspberry pi settings. In System>Information>Network, it shows the IP address, but the Internet: link is down. I can ping the pi, and I can connect to it just fine, but any outgoing connections fail. (I stream all of my library from a NFS share on my network). Only a restart fixes it.

There is a thingy that you can do with the wifi stick to have it on without power save mode…@sam_nazarko knows about it…i cant remember its name. Something you do using the console to disable power saving…It could be that.
Also try disabling the DIM option…try having the pi always on see if that helps.

As i said earlier, I have hardwired to Raspberry Pi 2 and I am not using Wifi dongle.

Recently I am noticing that, the Raspberry Pi disconnects even when i am playing something in OSMC. It does not seem like a network issue because other devices like Roku are still connected.

Sam, when my Raspberry Pi2 got disconnected, I was trying to run the ifconfig command as you suggested earlier. When I was trying to do this using the wireless USB keyboard connected to the Pi, I realized that, the USB keyboard was also disconnected. Do you think is it something to do with my Pi itself and how to fix this.

Do you have

max_usb_current=1

set? Having the USB keyboard drop at the same time indicates a power problem.

Is there any risk in setting max_usb_current=1? Just wanted to be sure.

There should be no risks. They recommend that setting all the time.

Ok. I did a fresh install of OSMC last night and set max_usb_current=1. Let me give it a day or two to see if the connection drops again.

Again, the internet and USB devices dropped yesterday, even after i set the max_usb_current=1.

To rule out the possibility of software issue, I installed Raspbian to see if the same issue happens there…In Raspbian, when the system boots I see a message briefly saying, “usb usb1-port 1 cannot enable. maybe the usb cable is bad?” …I am not sure if the message is really appropiate. I am using a Power adapter specifically made for Raspberry Pi and got it from Canakit and also there are no low voltage indication(rainbow screen)…I am not sure how to get past this issue.