Gloox文件传输小记

使用版本:1.1.10

今天弄了一下Gloox中自带的收发文件例子,收发文件的例子都是好使的,只不过,在调试过程中需要注意一些问题,下面将我遇到的问题做个记录(例子中以In-Band Bytestreams方式收发)

1、发送文件过程中遇到404错误
< iq  type ='error'  id ='uid-8509a748-00000005'  to ='wanghaiguang@wanghaiguang-wk/glooxsendfile'from='[email protected]/Spark  2.6.3' >< sixmlns ='http://jabber.org/protocol/si'  id ='uid-8509a748-00000006'  profile ='http://jabber.org/protocol/si/profile/file-transfer'> xmlns ='http://jabber.org/protocol/si/profile/file-transfer'  name ='d:\offline.bmp'  size ='6998'/> xmlns ='http://jabber.org/protocol/feature-neg'> xmlns ='jabber:x:data'  type ='form'> type ='list-single'var='stream-method'> label ='ibb'>http://jabber.org/protocol/ibb label ='oob'>jabber:iq:oob label ='s5b'>http://jabber.org/protocol/bytestreams code ='404'  type ='cancel'> xmlns ='urn:ietf:params:xml:ns:xmpp-stanzas'/>

可以将ip地址换成服务器名称试试
JID  j( "[email protected]/gloox" );——>  JID  j( "www@wanghaiguang-wk/gloox" );

2、发送文件过程中遇到503错误

< iq  type ='error'  id ='uid-8663a748-00000005'  from ='www@wanghaiguang-wk/glooxsend'to='wanghaiguang@wanghaiguang-wk/glooxsendfile'> xmlns ='http://jabber.org/protocol/si'  id ='uid-8663a748-00000006'  profile ='http://jabber.org/protocol/si/profile/file-transfer'> xmlns ='http://jabber.org/protocol/si/profile/file-transfer'  name ='d:\offline.bmp'  size ='6998'/> xmlns ='http://jabber.org/protocol/feature-neg'> xmlns ='jabber:x:data'  type ='form'> type ='list-single'  var ='stream-method'> label ='ibb'>http://jabber.org/protocol/ibb label ='oob'>jabber:iq:oob label ='s5b'>http://jabber.org/protocol/bytestreams code ='503'  type ='cancel'> xmlns ='urn:ietf:params:xml:ns:xmpp-stanzas'/>

这个问题可能是由于你接收端的资源名称与发送端 不匹配
// 接收端登录的jid
JID  jid( "[email protected]/glooxsendfile" );
 j =  new  Client( jid, "111" );

// 发送端的jid名称(发送给对方的jid名称)
JID  j( "www@wanghaiguang-wk/gloox" );
if ( j.resource().empty() )
{
     printf( "error: need full jid\n" );
      return  1;
}

你可能感兴趣的:(程序员之路)