The problem is either your WiFi network or your Friends is not compatible with the DS, Thus not letting you connect. Another problem is if your Friend Codes were either changed, or were put in wrong. The last issue is that since a lot of people are using WiFi to trade or battle, the connection jams and stops working or freezes and logs you out. This is the reason why the GTS almost never works for some people.