Android Socket Connection Refused ETIMEDOUT (Connection timed out) - java

I have created a server on my PC (localhost and port is 8080) and am trying to connect to it on my android device. But every time i try it gives me this error:
java.net.ConnectException: failed to connect to /10.0.2.2 (port 8080): connect failed: ETIMEDOUT (Connection timed out)
I have been looking online forever and looked at countless pages and have tried everything I could find.
-Switched the android host to 10.0.2.2
-Turned off firewall
-Changed the port
-Made sure both the PC and the android device where connected to the same internet connection
The Server code is written in Java and, just to make sure it works I tried making a connection to the server with another Java app. And it worked.
Thank you for your help, if you need any more info just let me know.

Do not use 10.0.2.2. That is for if your app runs on an emulator.
Use the LAN ip of your pc.
Find out with ipconfig.

Related

connection android studio to sql server

Please I have been trying to connect my android studio to my SQL server,but it's not working. It's giving me error of connection refused.
Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "connectivitycheck.gstatic.com": No address associated with hostname java.net.ConnectException: failed to connect to /10.20.37.39 (port 1433): connect failed: ECONNREFUSED (Connection refused)
I googled the error and from the results found out that the problem could have come from
firewall
not enabling tcp/ip
and using poor IP address.
I have tried to counter all of this but am still getting the error. I don't know what to do because am working on a school project. I have to submit soon. Again when I checked my SQL server log i saw a significant part of the SQL process has been page out.

Facing issue with ionic web-socket connection with java socket server

I am facing issue with websocket on Ionic
connection with "ionic serve" working perfect. but when i try with "ionic run android"(which is connected with WiFi) getting below given error.
"WebSocket connection to 'ws://192.168.1.7:8086/wsConn' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT"
"192.168.1.7" is my server ip address.
I tested server running on window 10 and window server 2012 both.
tried with turning off server firewall also.
Can anyone help me on this ?

connect failed: ECONNREFUSED

I am developing one app, and what I think I wanna do is receive data from server database in android. So I started to run some tutorials. I found one that is doing pretty much what I want.
But I am getting:
detailMessage "failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused)" (id=830021648792)
Whole code of this tutorial is here link
Error occurs on :
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
I checked that:
firewall is disabled
ping is working
connection string is exactly the same as when I run the servlet from server admin interface - http://localhost:8080/Requestor/RQSRV
-the servlet is running
My configuration :
Server : Glass Fish 4.0
Android App - Developed in Eclipse
Servlet - Developed in NetBeans
To access your PC localhost from Android emulator, use 10.0.2.2 instead of 127.0.0.1. localhost or 127.0.0.1 refers to the emulated device itself, not the host the emulator is running on.
Reference: https://developer.android.com/studio/run/emulator-networking#networkaddresses
For Genymotion use: 10.0.3.2 instead of 10.0.2.2
if you are using genymotion then go to command prompt type ipconfig
-find for Ethernet adapter virtualBox host-only network:
-find for Ipv4 Address..............192.1**.**.*
copy
http://192.1..*/foldername/filename/filename.json or filename.php
to check if its working go to browser in emulator copy paste the url you should find the file which you are looking in your browser..
Sorry for English..
This worked for me hope this might help some one..
Thank u..

java.net.ConnectException: failed to connect to /192.168.10.110 connect failed: ECONNREFUSED (Connection refused

First problem:
I am doing messaging using socket programming.Previously it worked fine but currently it is showing exception when I connect both server and client to same router .
Second problem:
If I connect server and client to different networks it is not working client unable to connect server's ip address
192.168.0.0/16 is a Local Area Network address block.
Moreover, if your server machine is configured to use DHCP instead of a static address, it may receive a different local address each time you connect it to the (same) router.

Android Emulator get port Number

The port for emulator 5554 is not working when I try to type the command: telnet localhost 5554
The error is:
Connecting To localhost...Could not open connection to the host, on port 5554:
Connect failed
How could it connect to port 5554 to let the android emulator sending socket, and the android emulator program on client server side give a message that does not work ( unfortunately client has stopped)
Check whether your port is open or not using this link.
http://www.yougetsignal.com/tools/open-ports/
If u have personal firewall try disabling that.

Categories