3

I'm developing a chat web client (XMPP based) using Strophe.js. On server side I have an Openfire server.

I'm looking for a complete (and working) example of file transfer (xep-0096) using Strophe.js.

I know there is a plugin, named si-filetransfer, which should help in implementing this feature but documentation is missing. So it is not easy to understand how it works.

Here on StackOverflow I found only some incomplete post relating the matter, as for example: Save received files from xmpp Strophe si-filetransfer

Also on the web I didn't find any complete solution to my needs.

If there is another solution to achieve the above goal (file transfer in a JS client using XMPP protocol) it 's welcome!

vp-platform
  • 601
  • 6
  • 17

1 Answers1

7

Here below is a very simple chat demo written using jQuery and StropheJS with file transfer features. Implementation of file transfer is based on these two Strophe.js plugins:

In addition, in order to allow the transfer of files greater than 65535 bytes it is also used a chunking algorithm.

Here is the Plunker: http://plnkr.co/edit/fYpXo1mFRWPxrLlgr123

P.S.: you have to deploy your own XMPP server and adapt the following code lines according to your configuration:

var server = 'mydomain.com';
var BOSH_SERVICE = 'http://127.0.0.1:7070/http-bind/';
beaver
  • 17,333
  • 2
  • 40
  • 66
  • I've tried your code and I noticed that occasionally it happens that ibb goes into timeout... Is there a solution for this issue? – vp-platform Feb 12 '16 at 12:28
  • 1
    You may use a more reliable connection changing from Http-bind (bosh) to Websockets, provided your server allows it. Obviously you have to change the connection url accordingly (i.e. ws://127.0.0.1:7070/ws/) – beaver Feb 12 '16 at 13:28
  • Thanks a lot @beaver! – vp-platform Feb 12 '16 at 13:59
  • @beaver $('#btnSendFile').bind('click', function() { console.log('File clicked:'); sendFileClick(); }); is missing. and does not work. – user914425 Apr 05 '16 at 16:39
  • @user914425 thanks, plunker updated – beaver Apr 05 '16 at 16:54
  • @beaver I am getting fileTransferHandler: err=Error: [object Element] error. You also need to call handleFileSelect. It is missing where it sets file object. – user914425 Apr 05 '16 at 17:45
  • 1
    @beaver I am getting ibb.open: err=Error: feature-not-implemented in function fileTransferHandler(file,err)? What does this mean? – user914425 Apr 05 '16 at 18:02
  • @user914425 maybe your server doesn't support IBB (check http://xmpp.org/extensions/xep-0047.html#create) – beaver Apr 05 '16 at 19:21
  • @beaver I am using the latest openfire 4.0.1. Instead of In-Band Bytestreams how about Out-of-Band Data. How do I make the code changes? – user914425 Apr 05 '16 at 19:25
  • @beaver can you also update the example to contain receiving files via both in band and out-of-band data? – user914425 Apr 05 '16 at 20:05
  • @beaver can you post a working example for out-of-band file transfer based on https://github.com/strophe/strophejs-plugins/tree/master/si-filetransfer? – user914425 Apr 07 '16 at 17:36
  • @vp-platform I also notice ibb sometimes goes into timeout and when succeed always file is zero size. – user914425 Apr 07 '16 at 17:41
  • @user914425 can you please say in details, how did you solve the error with err=Error: [object Element] error, cause I have this error now. Thank you in advance – BohdanZ Jul 12 '16 at 14:21
  • @beaver, or may be you know, how to solve this error. Thanks – BohdanZ Jul 12 '16 at 14:23
  • @BohdanZ can you send me code where you getting the err=Error: [object Element]? As I mentioned above I am constantly getting timeout error and when it succeeded I get a zero size file. See if you can implement out-of-band data transfer. You will have better luck here. – user914425 Jul 13 '16 at 23:50
  • @BohdanZ you might want to use this https://github.com/strophe/strophejs-plugins/blob/master/outofband/strophe.outofband.js. as a starting point. – user914425 Jul 14 '16 at 00:19