13

I have a problem and it is that, yesterday, I could access from my mobile phone to my computer network but today it doesn't work. Why it could be?

What I have ready:

  1. I have running my local server with XAMPP (I have started Apache and MySQL).
  2. I'm connect via WIFI to the same network.
  3. My mobile phone it's connect to the computer via USB.
  4. I went to CMD, copy the IP of my computer and put it on the browser of my mobile phone, but it doesn't work.
  5. I tried with the url 10.0.2.2 but it also doesn't work.

Why it could be? Yesterday it worked perfectly putting my url in my mobile phone browser and today it doesn't work. I didn't make any change from yesterday. Had I forgot something? How can I check that all it's working correct?

Note: I saw a lot of questions that makes the same question but I couldn't solve my problem with them.

Thanks in advance!

EDIT: I saw a problem in my log console. The log it's here:

06-04 16:49:21.527  17600-17600/com.example.user.project V/PhoneWindow﹕ DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{420a1478 com.example.user.project/com.example.user.project.MainActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{4205a608 V.E..... R.....ID 0,0-0,0}
06-04 16:49:21.527  17600-17600/com.example.user.project D/ActivityThread﹕ ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{4204b3c0 token=android.os.BinderProxy@4204aa68 {com.example.user.project/com.example.user.project.MainActivity}}
06-04 16:49:21.590  17600-17600/com.example.user.project E/﹕ appName=com.example.user.project, acAppName=/system/bin/surfaceflinger
06-04 16:49:21.590  17600-17600/com.example.user.project E/﹕ 0
06-04 16:49:21.590  17600-17600/com.example.user.project E/﹕ appName=com.example.user.project, acAppName=/system/bin/surfaceflinger
06-04 16:49:21.590  17600-17600/com.example.user.project E/﹕ 0
06-04 16:49:21.592  17600-17600/com.example.user.project D/GraphicBuffer﹕ create handle(0x614af178) (w:480, h:800, f:1)
06-04 16:49:21.593  17600-17600/com.example.user.project I/MaliEGL﹕ [Mali]window_type=1, is_framebuffer=0, errnum = 0
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
  • I don't think this should be on Stack Overflow, but Super User instead. This is about general computer hardware / networking and not programming. – user3791372 Sep 08 '15 at 19:18
  • From what I can understand, you are trying to access a XAMP stack hosted on a computer on your local network from a mobile device also connected on your local network. Please make sure your XAMP server is running, check at which port is the server listening for connections. Also, check the rules of your firewall. (whether incoming connections are allowed on the port which your server is listening. For starters, tell us on which operating system is your server hosted? – George Daramouskas Sep 08 '15 at 19:43
  • @GeorgeD Yes, I have checked that XAMPP it's running and all the steps that I put above are running. I think it is not a problem with the firewall because, with the same configuration, when this trouble comes, if I disable one moment the WIFI from my mobile phone and enable it again, it works (as I said on my answer below). It is the reason why I'm confused. All the configuration its the same before and after I disable/enable the WIFI. It seems that the conexion with the computer network get stuck sometimes. I'm using Windows 7. – Francisco Romero Sep 08 '15 at 20:42
  • @user3791372 I'm trying to remove this trouble forever. I don't care if it is by some configuration or to add some code to my application to avoid it (it's the final purpose of solve this trouble). It's why I put the question here. Sorry if it upsets to you. – Francisco Romero Sep 08 '15 at 22:41

4 Answers4

13

This is a solution that I found to make it works when this trouble happens. It is not technical (or I don't think so) but it works for me and it's the following:

  1. I connect my mobile device to the computer via USB.
  2. I run my server (in my case XAMPP).
  3. I'm connect via WIFI to the same network from my mobile device as from my computer.
  4. I went to CMD, copy the IP of my computer and put it on the browser of my mobile phone, but it doesn't work.

If I do the steps that I put above it doesn't work. So, what I have to do to solve this problem?

When I have configurated all the steps that I put above and this error ocurrs, I have to disable the WIFI from my mobile device. When I enable it again it works perfectly!

I don't have any idea about why it happens, and I know that it's not a very technical answer but I mark as accept because I think it can help another people.

If some of you have another solution to this problem or if you know why it is correct with my solution please let me know.

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
2

If the site isn't reachable locally (it's not clear from your question), it might be that Apache isn't really running. One common scenario is that Apache crashes, leaving behind a httpd.pid file indicating that Apache is still running even though it's not. This could explain why the error seems to occur randomly. Stop Apache, remove httpd.pid (possibly located at /opt/lampp/logs/httpd.pid) and start Apache again. Also, check the Apache log for errors. (The error log can be found in the <xampp-install-location>/apache/logs directory.)

emidander
  • 2,383
  • 22
  • 29
  • I edited my question now. I'm using a local server and using XAMPP for running `Apache` and `MySQL`. If I didn't missunderstood you, this problems only occurs when you are using an external server? – Francisco Romero Sep 08 '15 at 10:08
  • No, this applies to XAMPP and the Apache running as a part of XAMPP. It has happened to me several times. – emidander Sep 08 '15 at 10:15
  • And how can I remove it totally? The problem it's that I'm using an API REST and if I can't connect from my mobile to my computer network it won't display nothing on the application. And I don't want that my application sometimes run properly and sometimes it run but without displaying anything. – Francisco Romero Sep 08 '15 at 10:22
  • Well, I used to see this when I made changes to Apache configuration with XAMPP running, but you might have another problem altogether. Check the Apache/XAMPP log files for errors to be sure. – emidander Sep 08 '15 at 10:30
2

When you use a wifi network to communicate you don't need connecting the usb cable except of using usb debugging. I suggest the following solutions:

  1. Turn the windows firewall off. (or other antivirus firewalls or proxy softwares)
  2. Change your system IP address manually and use it in the android.
  3. Stop and start XAMPP. (If possible change the XAMPP default port).
  4. Check your mobile proxy setting. (you can simply forget the wifi and reconnect it).

Also to be sure if problem is from your PC or not you can use a second PC or Laptop and open the webpage from a browser.

Ahmad Behzadi
  • 1,006
  • 15
  • 30
  • Thank you for your answer! But I connect the mobile by usb cable because I have my database on my computer (in a local server). Also, because I run my Android application from Android Studio and choose my mobile as the device in which I want to run it. – Francisco Romero Sep 08 '15 at 10:14
  • As I said except of using usb debugging (for android studio) it is not important for database. you use the database from wifi network. (try other suggestion ). – Ahmad Behzadi Sep 08 '15 at 10:26
0

Maybe this helps someone else:

Simply reconnecting the laptop to the WiFi did the trick for me.

Joe
  • 877
  • 1
  • 11
  • 26