XMPP Openfire Connection Refused - android

I am using Openfire server its admin panel is running on my localhost. When i try to connect to it using android smack library on localhost, port 5222 it gives me Connection Error.
The credentials i am using is...
private static final String DOMAIN = "127.0.0.1";
private static final String USERNAME = "admin";
private static final String PASSWORD = "admin";
The Exception I am getting is...
SMACKException: The following addresses failed: '127.0.0.1:5223' failed because java.net.ConnectException: failed to connect to /127.0.0.1 (port 5223) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
However I have just installed openfire and then set it up. I can see the Admin panel on http://localhost:9090/ and can login using username and password as admin.
I tried google it but nothing seems like working for me. So can anyone help me to get it working? I am pretty new to openfire server so have very little knowledge about it.
Thanks in Advance.

Are you sure you connecting to port 5222?
SMACKException: The following addresses failed: '127.0.0.1:5223' failed because java.net.ConnectException: failed to connect to /127.0.0.1 (port 5223) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
Your stack point to 5223 (SSL) port.
Also, you have to use your public IP instead of localhost.
synchronized void configureConnection() {
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName(HOST);
config.setHost(HOST);
config.setPort(PORT);
config.setDebuggerEnabled(true);
XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
connection = new XMPPTCPConnection(config.build());
connection.addSyncStanzaListener(this, new StanzaTypeFilter(org.jivesoftware.smack.packet.Message.class));
}

please check:
Did you open 5222 and 5223 port on your openfire server? I've got "Can not connect" error like you, everythings is okay, but I didn't open 5222 and 5223 port to allow connect.
Check again the security configuration on your server to set the right config on client
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

hi i have implemented xmpp and below github link have example.Try to follow up thing.
https://github.com/saveendhiman/XMPPSample_Studio
here, you are missing according to me.You have to mention port number.Specified for xmpp is 5222.
ConnectionConfiguration config = new ConnectionConfiguration(HOST1,
5222);
SmackConfiguration.DEBUG_ENABLED = true;
SASLAuthentication.supportSASLMechanism("MD5", 0);
System.setProperty("smack.debugEnabled", "true");
config.setCompressionEnabled(false);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setReconnectionAllowed(true);
config.setSendPresence(true);
config.setRosterLoadedAtLogin(true);
Try this,Still you got any error or exception then tell me.
Thank you hope this will help you.

Related

How to use Twilio AndroidSDK behind sock proxy with Java System Property

I will use Twilio AndroidSDK. i need using Twilio AndroidSDK behind socks5 proxy.
I wrote this code under ClientActivity.java in twilio-mobile-quickstart
NEW IDEA: no use ProxySelector. only Systems Property Connecting..
protected void onCreate(Bundle savedInstanceState) {
System.setProperty("java.net.useSystemProxies","true");
System.setProperty("proxyHost","[Proxy Server Addr]");
System.setProperty("proxyPort","[Proxy Server Port]");
System.setProperty("http.proxyHost","[Proxy Server Addr]");
System.setProperty("http.proxyPort","[Proxy Server Port]");
System.setProperty("https.proxyHost","[Proxy Server Addr]");
System.setProperty("https.proxyPort","[Proxy Server Port]");
System.setProperty("socketsProxyHost","[SOCKS5 Server Addr]");
System.setProperty("socketsProxyPort","[SOCKS5 Server Port]");
I get new errors. can't connecting SSL.
i feel my device connect to host directlly.
Twilio this https connection can't connect with proxies? :(
in closed network, detect this log:
01-31 16:17:15.617 17711-30305/com.twilio.client.quickstart D/HttpLongPollThread: connecting to host matrix.twilio.com on port 443
01-31 16:17:15.697 17711-30305/com.twilio.client.quickstart W/HttpLongPollThread: long poller got exception
java.net.ConnectException: failed to connect to matrix.twilio.com/52.54.166.186 (port 443) after 30000ms: isConnected failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.isConnected(IoBridge.java:234)
at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.twilio.client.impl.net.HttpLongPollThread.setUpSocket(HttpLongPollThread.java:62)
at com.twilio.client.impl.net.HttpLongPollThread.run(HttpLongPollThread.java:287)
Caused by: android.system.ErrnoException: isConnected failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:171) 
at libcore.io.IoBridge.connect(IoBridge.java:122) 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452) 
at java.net.Socket.connect(Socket.java:884) 
at com.twilio.client.impl.net.HttpLongPollThread.setUpSocket(HttpLongPollThread.java:62) 
at com.twilio.client.impl.net.HttpLongPollThread.run(HttpLongPollThread.java:287) 
Anyone might have an idea where did i do wrong? Thanks in advance.
Twilio developer evangelist here.
I'm afraid the Twilio Client Android SDK does not currently support SOCKS proxies, which is why you are seeing these issues.
I recommend you get in touch with Twilio support with your requirements and they will be able to notify you if proxy support is added to the SDK.
Let me know if that helps at all.

Android application failing to connect to port 80

I am using this url in android application code as I am using genymotion.
String login_url = "http:// 10.0.3.2:8080/login.php";
But the exception in Logcat says
-java.net.ConnectException: failed to connect to /127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
I am not able to resolve this issue.
When I try to execute login.php separately.It runs on http://127.0.0.1/login.php
Thanks but I got the answer.There was a space in my url,which was incorrect.
So,For running it on genymotion emulator use url--->
String login_url = `"http://10.0.3.2:8080/login.php";`
And for android device use--->`
String login_url = "http://192.168.*.*/login.php";`

RabbitMqtt not listening to 1883 port

I want to use rabbitMqtt and I programming my client by android.but in android code i have MqttException for this line of code mqttClient.connect(generateClientId(), cleanStart, keepAliveSeconds);
when I get cause of this exception, that return this error:
java.net.ConnectException: failed to connect to /192.168.0.86 (port 1883) after 1200000ms: isConnected failed: ECONNREFUSED (Connection refused)
I guessed this problem comes from that perhaps my RabbitMqtt broker not listen to port 1883. My rabbitMqtt is running and I performed the server but I can't see any port by name of 1883 in Resource Monitor. please help me

AsyncHttpClient doesn't use the HTTPS port set in the constructor

I'm trying to change the port I'm using for HTTPS connection between my Android client and my server, but the port doesn't get set for some reason. I initialize the HTTP client like this:
// Use port 8185 for HTTPS
client = new AsyncHttpClient(80, 8185);
... but I get an Exception:
org.apache.http.conn.HttpHostConnectException: Connection to https://192.168.1.35 refused
...
Cause by: java.net.ConnectException: failed to connect to /192.168.1.35 (port 443) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
Based on these errors, it seems that the default port 443 is still being used. Why is that? Why can't I use the non-default port 8185?
Edit: This is the library I'm using.
From what I've read in the Javadocs and on the lib website, perhaps you could try something like:
AsyncHttpClientConfig cf = new AsyncHttpClientConfig.Builder().setProxyServer(new ProxyServer(ProxyServer.Protocol.HTTPS,"IP_ADDRESS", 8185)).build();
AsyncHttpClient c = new AsyncHttpClient(cf);

Android webservices connection refused

I am trying to access RESTful webservice from android using below code.
ClientConfig config= new DefaultClientConfig();
Client client=Client.create(config);
WebResource service=client.resource("http://localhost:8085/JerseyTest/jersey/test/testing123");
But am getting the following exception.
07-22 16:53:15.450: E/AndroidRuntime(1491): Caused by: com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8085): connect failed: ECONNREFUSED (Connection refused)
But the url is working well in broswers and i also tried with firewall turned off.Anyone could help me with this?
I think, You should change localhost by the ip of the computer where you have the WebService
Check whether u have added all the permission required and try IP address instead of localhost

Categories

Resources