I am using BrainTree Payment service in my android app.For server ,I am using php and XAMPP. Now when I use emulator and access server with "http://10.0.2.2:80".
IP address, everything works fine but if I put my laptop's IP address(where server is running),it does't work on android device and emulator.
I am getting :
"Connection Timeout Error"
Thank You !It turned out to be McAfee was blocking the connection request..SO after disabling McAfee,it worked!
(1) make sure both your android device and your laptop are on the exact same wireless network. This has to be the same router so I would avoid testing in a public area where there may be many routers serving a network.
(2) sometimes your firewall a might be blocking incoming connections, temporarily disable it.
(3) double check you're connecting to the correct IP address in your code. CMD -> ipconfig, then it's ipv4
Make sure you are using the ipv4 that you see when you type ipconfig into command prompt.
Try to disable Windows Defender, change Apache's require all granted config among others and try disabling the Windows firewall.
Related
I am currently doing POST request from android to PHP WAMP server. I am facing one problem, that is ,it refused to connect with the server (error 403) by using my mobile phone. On the other hand, my android emulator able to connect and perform POST action to PHP server.
String urlAddress = "http://192.168.43.133/Test/php_script.php";
HttpURLConnection con=Connector.connect(urlAddress);
int responseCode=con.getResponseCode();
In mobile phone debugger mode, I got 403 for the responseCode. Anyone faced this kind of problem before?
By default WAMPServer comes configured as a single desktop secure environment, to protect beginners form getting hacked.
So to access it from another device you must tell Apache that that is allowed.
Edit the httpd-vhosts.conf file. This is where the locahost Virtual Host is defined. Use the WAMPServer menu system.
wampmanager-> Apache -> httpd-vhosts.conf
Look for this line inside the ` and tag
Require local
If you want to allow access from your WiFi network then change it to comething liek this
Require ip 192.168.43
Note I used only 3 of the 4 quartiles. This says allow any ip address in the 192.168.43 range to connect to this Apache Virtual host
Try and avoid using
Require all granted
That is a hammer to crack a nut approach and if you ever open up your router would allow anybody in the universe to access your site.
Once you have edited the file and saved it, dont forget to restart Apache
wampmanager->Apache-> Service Administration->Restart Apache
This is network issue so make sure you have the following checked:
You firewall
Both your pc and phone are in the same LAN
Check if you can access your server from another device on the network
I had this issue, WAMP by defdault only accept conections coming from the same computer, so trying to access it from another device even though on the same network won't work, for that you need to first disable any firewall installed on your computer then go to windows firewall and add WAMP as an exception, and then try, if it doesn't work, then google how to allow connection from external devices to WAMP
I am using [ZKlib][1]
[1]: https://github.com/dnaextrim/php_zklib to connect to my ZK time and attendance machine. It is using UDP/SOAP to connect to device. Everything is working fine on localhost. But when I live it on server and try to access it though my public static ip that I have purchased from my ISP, even though I have port forwarded it, it cannot connect to the device. I have no issues in connecting to my IP cam through same router.
Another interesting fact is that if I make 3g Hotspot from my cellphone and connect my laptop to it. Now when I put public static IP of my router from which device is connected, and try to hit the device, Wow! Device is connected. But same application when I live it on server, even though I am on my 3g connection it could not connect to my device though my router that is port forwarded. I am wondering what is the issue with it when I live it.
I resolved it. It was issue with my host server. I had to talk to them to enable php_socket.dll extension on their server. Now it's running fine.
I have set up a websockets chat with the purpose of learning. Everything is working but I can't figure this issue out.
When I supply 127.0.0.1 as the address of the connection on the client side then I can access the server from the computer that's hosting it, but when I change the address to the actual LAN address of the hosting computer I can't connect the server even from the host itself. See:
Server = new FancyWebSocket('ws://127.0.0.1:9300'); Appears to work but only the computer that's hosting the server can connect ( for obvious reasons )
Server = new FancyWebSocket('ws://192.168.1.3:9300'); No computers can connect. I confirm 192.168.1.3 is the LAN address of the hosting computer.
What address do I need to put in there so that other computers from my local network can connect?
I solved the problem. Since it was a combination of two answers I thought the only fair thing to do was add another answer with an explanation.
As #Mehran suggested, I have had the server address set up as 127.0.0.1 instead of the network address. After changing that to 192.186.1.3 I was able to connect from the server itself, but other machines were unable to connect. Then I did the steps from the guide provided in #vtortola's answer to add a new inbound rule into the server's firewall in order to allow that port to be used.
So finally it all works now, thank you very much for helping me. +rep to everyone!
I'm pretty sure this is due to the configuration of your WebSocket server. It must be listening to localhost (127.0.0.1) to accept incoming connections in which case it won't answer to those aiming 192.168.1.3.
Since you didn't mention which server you are using I can not be specific but in general there are two ways to instantiate a listening socket, binding it to a specific IP address or * to bind whatever addresses system has. You need to configure the later if you intend to answer server connections coming from any computer within your LAN.
It looks like a Firewall/Policies issue to me.
IIS 7 Windows 2008, Localhost work but not local ip or external ip
Your TCP 80 could be allowed because the IIS installation will open it, that will explain why normal web browsing works. But you are trying to connect to the TCP 9300, that is very unlikely that is allowed by default.
Give a try to this: How to Open a Port in the Windows 7 Firewall , and allow that port.
Here are some things that you can safely assume while troubleshooting this issue:
If the service is able to work on 127.0.0.1 on the same machine, you can assume that the problem is not in the code or the PHP configuration
If you are not receiving an error when the server tries to bind to 192.168.1.3:9003 you can safely presume that the service is working. Try opening the Resource Monitor to see if it is actually listening on this port to confirm. To do so, go to 'Start Menu' in Windows and type 'Resource Monitor' in the 'Search programs and files' box. After opening the Resource Monitor, click the 'Overview' tab and find the name of the server process (typically 'php' if your using a CLI). With your process selected, switch over to the 'Network' tab and you will be able to see if it is listening on any ports within the 'TCP Connections' panel. This will show you what address and port it is listing on, as well as the remote address and port of any clients connected to the service.
If you know the server is running, and you know that it is actively listening on the expected address and port, it is very likely a firewall issue within Windows or your router. Note that even though 192.168.1.3 is the IP assigned to your interface, this is not a local IP and all communication to and from 192.168.1.3 will still go through the Windows firewall, including if being sent on the same machine. If your already at this point, I would strongly suggest checking your windows firewall first. If it is not the Windows firewall, check your router to see if it is blocking the port, and also check port forwarding and other setting to make sure that the router isn't otherwise interfering. We can likely help you with router issues here, but have your router's manual handy.
HTTP is a common service port so it is very possible that the router is not blocking the port, and windows may have automatically opened it if you are using IIS. 9300 is not a common port so it is unlikely to be open by default under any situation, unless your default is "all in", which effectively means your not using a firewall.
Another thing you might try (if possible) is closing your existing HTTP service and bind to port 80 using your Websocket service, or if possible (and while exercising caution) turn off your windows firewall completely to see if it works long enough to connect.
In general, don't try to reach your local network IP address from your own machine. There are very confusing things that happen at the socket layer here that I'll try not to delve too far into. The OS goes out of its way to make this work. Sometimes. I would expect that you cannot reach 192.168.1.3 (the server I'm assuming) from itself. There's a translation between local endpoint addresses when you do that which complicates everything.
A network switch will typically not send a frame back down a port it just received it from, so what you're seeing when you ping your local IP in cmd prompt is a loopback shortcut the OS is taking.
Not being able to reach it from another machine causes me suspect that the socket is not bound correctly on the server. Double check that you are explicitly declaring the socket on the server (address and port), and that your're binding your listener to that socket. Also ensure that the address you're binding to is for the correct network adapter. I see this all the time with laptops or machines that have multiple connected adapters.
Unfortunately I cannot be more targeted with my response as I am unfamiliar with what a FancyWebSocket is or how it is constructed.
I can help you if its a linux system.
If there is no name server on the local network, it is still possible to establish a small table mapping IP addresses and machine hostnames in the /etc/hosts file, usually reserved for local network stations.
This file is available even during network outages or when DNS servers are unreachable, but will only really be useful when duplicated on all the machines on the network. The slightest alteration in correspondence will require the file to be updated everywhere. This is why /etc/hosts generally only contains the most important entries.
This file will be sufficient for a small network not connected to the Internet, but with 5 machines or more, it is recommended to install a proper DNS server.
Try adding all the 'ip:port' along with a hostname and copy the template in file /etc/hosts in all the system.
Hope it resolves the issue!
Hello I have a problem in accessing the localhost in my android device. I can't open my localhost in my browser. I installed an application that supports httpd, php and mysql. But when I have a connection in the Internet there's no error in displaying the localhost. But if I disable it, I can't open the localhost. Is there a configuration file that I need to configure in my device? I am using ICS. I am using 127.0.0.1 as my localhost I also did 127.0.0.1:8080 but it doesn't work also.
If you're trying to access your web server over your local network, then you'll need to bind the web server to an IP address that the device can access - this is not 127.0.0.1. Assuming you're on wifi with your android, you'll want to have your web server listen to something along the lines of 192.168.1.X. If you use 0.0.0.0 it will accept on all interfaces, this should work as well. Either case, you'll need to access your web server from your device using your web server's local IP address, not localhost and not 127.0.0.1
Localhost as the url in a browser should access the server running on that device.it sounds to me maybe you are connected to a remote desktop or something. Tcp/ip utilities in particular try tracert localhoast or route. config /release maybe your touting tables are messed up,weird
The localhost refers to the device on which the code is running, in this case the emulator.
If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead 127.0.0.1. You can read more from here.
I encountered the same problem while working with my localhost too. The problem turns out to be with the antivirus that i was using. I was able to access my locahost again after turning the antivirus off. But because i cannot continue using my machine without an antivirus I just have to change the antivirus to another one. It worked for me, Hope it will for you too.
I am trying to test a php website using the web browser in android device (Google Nexus S). The Android version is 4.0.3. I have installed WampServer on my machine (running Windows 7) and have copied my php code in the wamp/www directory. I am able to test the code by browsing to localhost from the web browser on my machine. To test from my android device I tried browsing to my machine's public IP address, but the browser just gets stuck and doesn't load the page.
Does anyone know a solution to this problem ?
Thanks.
If you are browsing to your PUBLIC IP you need to ensure your Windows 7 firewall is allowing traffic on that port. Browsing from your localhost most likely works because your firewall doesn't block local traffic. Browsing to your PUBLIC IP means you are going out to the internet, hitting your firewall (router/windows 7?), and then trying to get to your server. Do you have port forwarding setup on your router? Have you tried accessing your local LAN IP rather than your public IP?
Here's what I did:
References :
http://forum.wampserver.com/read.php?2,13744
http://forum.wampserver.com/read.php?2,30970,30989
I changed Apache httpd.conf to listen at port 8080 instead of 80.
Also I added a new inbound rule in my windows firewall to allow port 8080 TCP connections.