|Are you using WIFI or wired connection to your modem/router?|
If the problem only happens when wired, check if your charger AC plug.
If you AC plug has a ground pin, isolate it and check if it changes your connection speed.
If you are experiencing this on WIFI, check if there is any update or other app running in background. It may be started/running when you are in charging mode only.