Unable to connect to ejabberd localhost - xmpp

I am tyring to connect to the ejabberd localhost from my android application The ejabbered server does not show the online user on ejabberd web admin.
AbstractXMPPConnection conn1;
conn1 = new XMPPTCPConnection("MyID#localhost", "password", "192.168.1.23");
conn1.connect();
if(conn1.isConnected())
{
Toast.makeText(this,"conn 1 successfull",Toast.LENGTH_LONG).show();
}
// Create a connection to the jabber.org server on a specific port.
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("MyId#localhost", "password")
.setServiceName("jabber.org")
.setHost("192.1**.1.2*")//My Ip address
.setPort(5222)
.setDebuggerEnabled(true)
.build();
AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
conn2.connect();
if(conn2.isConnected())
{
Toast.makeText(this,"conn2 successfull",Toast.LENGTH_LONG).show();
}

Your code seems incorrect:
Username should be the username without XMPP domain (Just MyId).
ServiceName is set to "jabber.org", which mean you will try to connect to that server, not your local server.

Related

WiFiP2PManager Connect WiFiP2PConfig - pass port number to client?

I've implemented a Xamarin app that successfully peers to another instance of itself running on another device using WiFiP2PManager, OnPeersAvailable and OnConnectionInfoAvailable (etc.).
My challenge now is I'd like the group owner to specify the PORT the client(s) will use to connect.
SERVER
var serverSocket = new ServerSocket(port); <<< PASS THIS PORT NUMBER TO THE CLIENT.
client = serverSocket.Accept();
CLIENT
client = new Socket();
InetSocketAddress socketAddress = new InetSocketAddress(address, port); <<< PORT PASSED FROM THE SERVER
client.Connect(socketAddress);
Is there any way I can pass additional information to the peer that it can use for connection, such as the port number?
Thanks
-John

Remote Kafka JMX - Connection refused

I am running kafka10 on a remote server and the JMX is enabled on port 9999.
JMX URL :- service:jmx:rmi:///jndi/rmi://kafka_host:9999/jmxrmi
When i try to connect to the JMX from my local network, it works fine and getting response within few secs.
But when i try to connect from my test servers, we get connection refused.
The ACL is opened from this host to the kafka host on port 9999.
Application code,
TopicJMXMetrics jmxMetrics = new TopicJMXMetrics();
JMXServiceURL serviceURL = new JMXServiceURL(jmxUrl);
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, null);
MBeanServerConnection connection = connector.getMBeanServerConnection();
Is there any other setting required from Kafka or on the Application Side? Or, any other port to be opened
Thanks

smack is connecting to ejabberd server

Here is my smack code to connect ejabberd server
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
builder.setUsernameAndPassword("admin#manish-lenovo-g510", "admin");
builder.setServiceName("manish-lenovo-g510");
builder.setHost("192.168.1.2");
builder.setPort(5280);
XMPPTCPConnectionConfiguration build = builder.build();
AbstractXMPPConnection conn1 = new XMPPTCPConnection(build);
conn1.connect();
I am getting this error:
Exception in thread "main" org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was 'null'.
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:106)
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:85)
at org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoint.java:253)
at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(SynchronizationPoint.java:146)
at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWaitOrThrow(SynchronizationPoint.java:125)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:837)
at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:365)
if i open admin interface of ejabberd its opening so Why this code is not working. One more thing how to find the service name as i guess that might be the issue as i dont know the service name, i have given it randomly.
I think port should be the standard XMPP port which is 5222. 5280 is the port for web admin, which speaks HTTP, not XMPP.

Sending a mail with Sendgrid from a Grails 2.0 application on Heroku

I'm trying to send emails from my Grails 2.0 app via Sendgrid on Heroku but I can't find the right configuration. I keep getting "Connection refused" exceptions:
java.net.ConnectException: Connection refused
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:288)
at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:102)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:39)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:149)
The latest configuration I tried is the following:
grails {
mail {
host = "smtp.sendgrid.net"
port = 587
username = System.env.SENDGRID_USERNAME
password = System.env.SENDGRID_PASSWORD
props = [
"mail.smtp.protocol":"smtps",
"mail.smtp.channel":"plain",
"mail.smtp.auth":"true",
"mail.debug":"true"
]
}
}
It looks like you might have a firewall or ISP blocking port 587. Try this: http://support.sendgrid.com/entries/131119-help-smtp-port-25-is-being-blocked
Elmer Thomas, Developer Evangelist at SendGrid.com
Actually, the problem came from my Grails configuration. For some reason, my mail config was reset at some point and what I had in Config.groovy was not used. So the app tried to send emails via localhost and that didn't work. I found a workaround to this problem but I don't understand yet why it works.

Tomcat as Clients communicating with multiple separated Servers via SSL

Here is the scenario:
I have multiple application servers running locally for now (should be running in different host) --> each is listening on different port (at localhost).
I have a single client application running on Tomcat.
When startup Tomcat, login with different user's details with connect to different (above) servers remotely.
My problem is:
First, I startup Tomcat and logged in as userA, it then connected successfully to serverA(localhost:1000).
Then I logged out.
Logged in again as userB, it did NOT connect to serverB(localhost:1001) as expected; instead, it gave exception
"javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown"
However, if I restart Tomcat, and login as userB first, it then connects successfully to serverB.
Does anyone know what the problem is?
I really appreciate any suggestion :)
Code for client Tomcat:
SetupClientKeystore();
SetupServerKeystore();
SSLContext context = SetupSSLContext();
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
SSLSocket socket = (SSLSocket) socketFactory.createSocket(hostname, portNo);
GZIPOutputStream gZipOut = new GZIPOutputStream(socket.getOutputStream()); // no trust certificate found throws here
Code for serverA and B:
setupClientKeyStore();
setupServerKeystore();
setupSSLContext();
server = new ServerSocket(portNo);
SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
serverSocket = (SSLServerSocket) socketFactory.createServerSocket(portNo);
serverSocket.setNeedClientAuth(true);
while ( true )
{
Socket client = serverSocket.accept();
inStream = client.getInputStream();
BufferedInputStream bufferedIn = new BufferedInputStream(inStream); //unknown_certificate throws here
//do something here.....
}
"javax.net.ssl.SSLHandshakeException: Received fatal alert:
certificate_unknown"
This usually indicates that the server's certificate is not trusted.
Could it be that when you log-in as userA you load the trusted certificate of serverA and connect, and then when you try to connect to serverB you try to authenticate serverB using the certificate of ServerA (loaded when you logged in as userA)?
As a result the SSL handshake fails.
So when you restart and login as userB the appropriate certificate (i.e. of ServerB) is loaded and the connection is succesfull?
You have no code in your post but if you do it as I say, this explains the exception.