powered by Jive Software

The Spark Client is not responding!

My Code:

public class Communicate {

public static String sendData(String str, Socket s, DataOutputStream dos)

{

byte[] buff = new byte[1024];

try

{

System.out.println("Client Send–> "+str);

dos.write(str.getBytes());

BufferedInputStream bis = new BufferedInputStream(s.getInputStream());

bis.read(buff);

System.out.println("Server Send–> "+new String(buff).trim());

}catch (Exception e) {

// TODO: handle exception

}

return new String(buff).trim();

}

public static void main(String args[])

{

try

{

String recieve = “”;

Socket s = new Socket(“localhost”,5222);

DataOutputStream dos = new DataOutputStream(s.getOutputStream());

DataInputStream dis = new DataInputStream(s.getInputStream());

            String str1 ="<stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='[http://etherx.jabber.org/streams](http://etherx.jabber.org/streams)' version='1.0'/>";

                //"<stream:stream       to='localhost'       xmlns='jabber:client'       xmlns:stream='[http://etherx.jabber.org/streams](http://etherx.jabber.org/streams)'       version='1.0'>";

                //"<stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='[http://etherx.jabber.org/streams](http://etherx.jabber.org/streams)' version='1.0'>";

recieve = sendData(str1, s, dos);

String msg = “”;

byte[] auth_msg = (“rajat” + “@” + “localhost” + “\0” + “rajat” + “\0” + “rajat”).getBytes();

msg = msg + Base64.encodeBase64String(auth_msg) + “”;

sendData(msg, s, dos);

            msg = "<stream:stream xmlns='jabber:client' xmlns:stream='[http://etherx.jabber.org/streams](http://etherx.jabber.org/streams)' to='" + "localhost" + "' version='1.0'>";

String temp = sendData(msg, s, dos);

String resc = temp.substring(temp.indexOf(“id=”)+4,temp.indexOf(“xml:lang”)-2).trim();

msg = “”;

sendData(msg, s, dos);

File f = new File("/root/Desktop/checkfile/myfile.txt");

System.out.println(f.exists());

double size = f.length();

long date = f.lastModified();

Date dt = new Date(date);

byte[] buff = new byte[(int)size];

FileInputStream fis = new FileInputStream(f);

fis.read(buff);

String hash = Md5Crypt.md5Crypt(buff);

            msg = "<iq from='rajat@localhost' to='admin@localhost' id='disco1' type='get'><query xmlns='[http://jabber.org/protocol/disco#info'/](http://jabber.org/protocol/disco#info'/)></iq>";

sendData(msg, s, dos);

            msg = "<iq id='vrC08-126' to='admin@localhost/Spark 2.6.3' from='rajat@localhost/Spark 2.6.3' type='set'><si xmlns='[http://jabber.org/protocol/si](http://jabber.org/protocol/si)' id='jsi_5471441136722873260' profile='[http://jabber.org/protocol/si/profile/file-transfer](http://jabber.org/protocol/si/profile/file-transfer)'><file xmlns='[http://jabber.org/protocol/si/profile/file-transfer](http://jabber.org/protocol/si/profile/file-transfer)' name='"+f.getPath()+"' size='"+(int)size+"'><desc>Sending</desc></file><feature xmlns='[http://jabber.org/protocol/feature-neg](http://jabber.org/protocol/feature-neg)'><x xmlns='jabber:x:data' type='form'><field var='stream-method' type='list-multi'><option><value>[http://jabber.org/protocol/bytestreams](http://jabber.org/protocol/bytestreams)</value></option><option><value>[http://jabber.org/protocol/ibb](http://jabber.org/protocol/ibb)</value></option></field></x></feature>  </si></iq>";

sendData(msg, s, dos);

}catch (Exception e) {

System.out.println(e.toString());

}

}

}

Response on Console:

Client Send–> <stream:stream to=‘localhost’ xmlns=‘jabber:client’ xmlns:stream=‘http://etherx.jabber.org/streams’ version=‘1.0’/>

Server Send–> <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“localhost” id=“f8264194” xml:lang=“en” version=“1.0”>stream:featuresDIGEST-MD5PLAINANONYMOUSCRAM-MD5</mech anism>zlib</stream:features>

Client Send–> cmFqYXRAbG9jYWxob3N0AHJhamF0AHJhamF0

Server Send–>

Client Send–> <stream:stream xmlns=‘jabber:client’ xmlns:stream=‘http://etherx.jabber.org/streams’ to=‘localhost’ version=‘1.0’>

Server Send–> <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream=“http://etherx.jabber.org/streams” xmlns=“jabber:client” from=“localhost” id=“f8264194” xml:lang=“en” version=“1.0”>stream:featureszlib</stream:features>

Client Send–>

Server Send–> rajat@localhost/f8264194</b ind>

true

Client Send–> <query xmlns='http://jabber.org/protocol/disco#info’/>

Server Send–>

Client Send–> Sendinghttp://jabber.org/protocol/bytestreamshttp://jabber.org/protocol/ibb

“As the Spark client on the other side ‘Accepts’ the file transfer, Server did not sends any Acknowledgement on the console in response---->>”

Please let me know , What to do !!!