Connection of Android Studio with localhost timed out - java

I have connected my Android App to WAMP server and I am running it on my mobile phone but each time I run the app, it gives the error:
Exception: failed to connect to /192.168.1.5 (port 9090): connect
failed: ETIMEDOUT (Connection timed out)
I am giving this URL:
String url = "http://192.168.1.5:9090/phpmysql.php";
Can anyone tell me what am I doing wrong? I saw this link too but wasn't much helpful.

Use 10.0.2.2 for emulator.
I think the url you are using is creating problems.
If it doesn't fix this error, try resetting the adb connection by force closing it from task manager and restarting the emulator. Also the wamp server should be running and should be accessible from your local browser.

Related

android app works on emulator but not in real device

My app is working fine in AVD but when i try to run my app in my mobile it is showing this error. It is not connecting to server. It is not accessing php file. I have given path for php file is "http://10.0.0.72/myapp/search.php". I'm using wamp server and kept my php file inside www folder.
Logcat Error
java.net.ConnectException: failed to connect to /10.0.0.72 (port 80):
connect failed: ETIMEDOUT (Connection timed out) 06-13 13:19:20.229
13823-14092/com.myapp W/System.err: at
libcore.io.IoBridge.connect(IoBridge.java:114)
Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
I assume that you run your wamp server in local PC. Connect both your phone and PC (which has the wamp server) to the same network and replace 10.0.0.72 with the private IP of the PC.
Try the url in the phone browser, It should be accessible.
Make sure you have given internet permission in the manifest file.

How to connect to a running bigtable emulator from java

I am trying to use the bigtable emulator from gcloud beta emulators.
I launch the emulator, grab the hostname (localhost) and port (in this instance 8885)
gcloud beta emulators bigtable start
Executing: /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/bigtable-emulator/cbtemulator --host=localhost --port=8885
I am trying to connect to the emulator from a java test client,
here is what I provide:
Configuration conf = BigtableConfiguration.configure(projectId, instanceId);
if(!Strings.isNullOrEmpty(host)){
conf.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, host);
conf.set(BigtableOptionsFactory.BIGTABLE_PORT_KEY, Integer.toString(port));
}
connection = BigtableConfiguration.connect(configuration);
try (Table table = connection.getTable("tName")){
table.put(<Put instance>);
}
When I execute the test code I get:
16:36:37.369 [bigtable-batch-pool-1] INFO com.google.cloud.bigtable.grpc.async.AbstractRetryingRpcListener - Retrying failed call. Failure #1, got: Status{code=UNAVAILABLE, description=null, cause=java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885}
java.net.ConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:8885
I am using the library: com.google.cloud.bigtable:bigtable-hbase-1.2:0.9.1
Any idea of what I am doing wrong ?
Thanks !
You need one additional config property to be set:
conf.set(BigtableOptionsFactory.BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true);
Also, from the log message it looks like it's trying to connect to an IPv6 address, which I don't think will work. Double-check that host is a valid IPv4 address.
The java client will make this easier to do in the near future.
Now you can set
configuration.set(BigtableOptionsFactory.BIGTABLE_EMULATOR_HOST_KEY,<HOST:PORT>); to connect to an emulator.
Also "https://github.com/googleapis/java-bigtable/tree/master/google-cloud-bigtable-emulator" can be used to start emulators programmatically for tests etc.

Pubnub Socket Timeout exception

This is the error I get in PubNub, when I publish. I am publishing from a normal Java file on eclipse.
[Error: 103-2] : HTTP Error. Please check network connectivity. Please contact support with error details if issue persists. : java.net.SocketTimeoutException: connect timed out
My network is connected and is working. Ping requests to google & other servers are successful. Yet, the error keeps occurring randomly.

java.net.UnknownHostException: Unable to resolve host "www.omdapi.com": No address associated with hostname

When I try to run my android app, I following error:
"java.net.UnknownHostException: Unable to resolve host "www.omdapi.com": No address associated with hostname".
The URL I'm contacting is correct. I have tried restarting wifi on my phone which is connected to the computer when I run my app, I have tried 4G instead of WiFi, and I have tried restarting my computer. But it still shows this long error: http://pastebin.com/LZsc2w45
Do anyone know what's wrong?

java and access error when connecting to the database

Today I encountered the following problem. When connecting to a database, the following error.Appeal to the remote database by connecting through vpn.
Added necessary firewall ports and even tried to disconnect its(did not help)
Added record to $JAVA_HOME/jre/lib/security/java.policy
grant codeBase "file:/-" {
permission java.security.AllPermission;
};(did not help)
If trying to connect with same data through sql management studio, it works and there is access. from the development environment no connection
Example(string connection = jdbc:sqlserver://DEVMSSQL14.test.com:1433;SCHEMA=test;DATABASENAME=test, sql managment studia = DEVMSSQL14.test.com,1433)
on another computer it works without problems, the same version of the project
It remains only to "Permission denied: connect".Maybe somebody faced with similar
Error:
The TCP/IP connection to the host DEVMSSQL14.test.com, port 1433 has failed. Error: "Permission denied: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
In the error message, you have shown like DEVMSSQL14.test.com, 1433 has failed.
I believe, it is correct. I dont think. this host name is correct. which says "TEST" as domain
Open the cmd, try to ping DEVMSSQL14.test.com
Success case :
If you are able to ping, then make sure the services are running for sql in services
Failure case:
Get the right host name to establish the connection
When i tried, i got this message, because i may be out of network.
Pinging DEVMSSQL14.test.com [208.64.121.161] with 32 bytes of data:
Request timed out.
Request timed out.
Try setting a System Property while running the code.
The catch is to introduce this line in code: System.setProperty("java.net.preferIPv4Stack", "true");
Or to pass it in VM option: -Djava.net.preferIPv4Stack=true

Categories

Resources