I am developing a chat function in my app. Using the code below I was able to connect to openfire and smackx to connect and login. everything was working fine. Unfortunately, openfire does not have acknowledgment xep in it yet. I wanted to use mod_stanza_ack by mingism for this purpose. Unfortunately, ejabberd2.1.11 cannot login with the error below in logcat. I have tried all variations to login but I get the same error or it just doesn't login but it can connect to server. This definitely is not due to switch of wifi and gsm. Could anyone please help out?
Code for connecting and logging in :
public void init() throws XMPPException {
// for connecting to ejabberd2 and logging in. could connect but cannot login
ConnectionConfiguration connConfig = new ConnectionConfiguration(ip_address, 5222,
ProxyInfo.forDefaultProxy());
//for connecting to openfire and logging in. works fine.
//ConnectionConfiguration connConfig = new ConnectionConfiguration(ip_address);
//connConfig.setReconnectionAllowed(true);
connConfig.setSASLAuthenticationEnabled(false);
connection = new XMPPConnection(connConfig);
// Connect to server
try {
connection.connect();
System.out.println("Connected to " +
connection.getHost());
}
catch (XMPPException ex) {
System.out.println("Failed to connect " +
connection.getHost());
}
}
public void performLogin(String username, String password) throws
XMPPException {
if(connection!=null && connection.isConnected()){
// Login to server
System.out.println("Logging in...");
try {
connection.login(username, password);
System.out.println("Logged in as " + connection.getUser());
// packet listener: listen for incoming messages of type CHAT on the connection (whatever the buddy)
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
connection.addPacketListener( packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Logcat: 03-24 22:52:27.771: W/System.err(31926): java.net.SocketException: sendto failed: EPIPE (Broken pipe) 03-24 22:52:27.781: W/System.err(31926): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506) 03-24 22:52:27.781: W/System.err(31926): at libcore.io.IoBridge.sendto(IoBridge.java:475) 03-24 22:52:27.781: W/System.err(31926): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507) 03-24 22:52:27.781: W/System.err(31926): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46) 03-24 22:52:27.781: W/System.err(31926): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269) 03-24 22:52:27.781: W/System.err(31926): at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167) 03-24 22:52:27.781: W/System.err(31926): at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158) 03-24 22:52:27.781: W/System.err(31926): at java.io.BufferedWriter.flush(BufferedWriter.java:124) 03-24 22:52:27.781: W/System.err(31926): at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:168) 03-24 22:52:27.781: W/System.err(31926): at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:40) 03-24 22:52:27.781: W/System.err(31926): at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:69) 03-24 22:52:27.781: W/System.err(31926): Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe) 03-24 22:52:27.791: W/System.err(31926): at libcore.io.Posix.sendtoBytes(Native Method) 03-24 22:52:27.791: W/System.err(31926): at libcore.io.Posix.sendto(Posix.java:151) 03-24 22:52:27.791: W/System.err(31926): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177) 03-24 22:52:27.791: W/System.err(31926): at libcore.io.IoBridge.sendto(IoBridge.java:473) 03-24 22:52:27.791: W/System.err(31926): ... 9 more
0 comments:
Post a Comment