Problems connecting to wildfire server through smack on a single machine

hi … i hava a very strange error… i wrote a little bot and tested it on my system … it worked well (windos java 6 and java 1.508) then i tried it on my server and got this messages:

smilingj@dergraf:~/serversoftware/ChronoBot$ ./run.sh

java.net.SocketException: Socket closed

at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)

at java.net.SocketOutputStream.write(SocketOutputStream.java:136)

at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)

at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404)

at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:408)

at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)

at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)

at java.io.BufferedWriter.flush(BufferedWriter.java:236)

at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:260)

at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:39)

at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:79)

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:5 01)

at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:343)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:720)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImp l.java:1025)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:10 38)

at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:11 21)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:327)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:63)

java.lang.IllegalStateException: Not connected to server.

at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:699)

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:54)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 213)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:426)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:389)

at net.smilingj.xmpp.chronobot.main.ChronoBot.setUpConnection(ChronoBot.java:99)

at net.smilingj.xmpp.chronobot.main.ChronoBot.start(ChronoBot.java:73)

at net.smilingj.xmpp.chronobot.main.ChronoBot.main(ChronoBot.java:163)

Exception in thread “main” java.lang.IllegalStateException: Not connected to server.

at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:699)

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:54)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 223)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:426)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:389)

at net.smilingj.xmpp.chronobot.main.ChronoBot.setUpConnection(ChronoBot.java:99)

at net.smilingj.xmpp.chronobot.main.ChronoBot.start(ChronoBot.java:73)

at net.smilingj.xmpp.chronobot.main.ChronoBot.main(ChronoBot.java:163)

but not always in 1% of all tries i got a connection and everything worked well. … the system on the server is a debian testing with java 1.508 … and so i tried it out under suse linux 10.2 … (java 1.509) - what should i say? it worked well…

but it’‘s supposed to work on the server … an i’'d like to know how i get it into this state…

perhaps it’'s because of the wildfire server thats running on the server too… but why does it work - sometimes …

anyone an idea?

by now i knwo what causes the problem … the socket which is used by smack is not released fast enough and so smack throws exceptions…

a friend told me that in c there is a possibility to avoid this kind of problems by coding a line like this

on = 1;

ret = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on) );

now i’‘m not firm enough with java to translate this into java . but it may be a proposal for the next smack version … so that this kind of error won’'t appear in future.

Hi,

are you using the Smack 3.0 beta build for your bot?

LG

no. i used the most recent 2.x.x build … the 3.x wasn’'t out at the time my problems started …

why do you ask? is it better with smack 3?

PS: i dont want to switch to 3.x since the api is not stable - i dont like writing facades

Message was edited by: SmilingJ

Hi,

I wonder if this is fixed in Smack 3.0.0 and I’‘m quite sure that you will not get a fix for a 2.x version. If it’'s a Smack 3.0 bug one could create an issue to get it fixed.

LG