问题描述
进来记录此错误。
从='kutbi1 @ 360度/啪'给='阿卡什@ 360度/啪'的类型='错误'ID ='hK1L6-5'>
< SI的xmlns =HTTP://jabber.org/protocol/si'ID ='jsi_191216212994140179'MIME类型=图像/ PNG的个人资料=HTTP://jabber.org/protocol/si/profile/file -Transfer'>
<文件中的xmlns =HTTP://jabber.org/protocol/si/profile/file-transferNAME ='this_old_house.png'大小='12623'>
<说明>您获得了与放大器;者;吨认为该<!/递减>< /文件>
<特征的xmlns =HTTP://jabber.org/protocol/feature-neg'>
&其中,X的xmlns ='胡言乱语:X:数据类型='形式'><现场VAR ='流法类型='列表多'>
&LT;选项&GT;&LT;价值&GT; HTTP://jabber.org/protocol/bytestreams< /值GT;&LT; /选项&GT;
&LT;选项&GT;&LT;价值&GT; HTTP://jabber.org/protocol/ibb< /值GT;&LT; /选项&GT;
&LT; /场&GT;
&LT; / X&GT;
&LT; /功能&GT;
&LT; / SI&GT;
&LT;错误code ='503'型='取消'&GT;
&LT;服务不可用的xmlns =金塔:IETF:params:一个XML:NS:XMPP协议,叙述/&GT;
&LT; /错误&GT;&LT; / IQ&GT;
我这里使用以下code
ServiceDiscoveryManager SDM = ServiceDiscoveryManager.getInstanceFor(Main.connection);
如果(SDM == NULL)
SDM =新ServiceDiscoveryManager(Main.connection);
sdm.addFeature(http://jabber.org/protocol/disco#info);
sdm.addFeature(胡言乱语:IQ:隐私);
FileTransferNegotiator.setServiceEnabled(Main.connection,真正的);
FileTransferManager经理=新FileTransferManager(Main.connection);
OutgoingFileTransfer转移= manager.createOutgoingFileTransfer(ID
+/啪);
Log.i(outgoingfiletransfere创建,transfere文件);
尝试{
//OutgoingFileTransfer.setResponseTimeout(60000);
transfer.sendFile(新文件(txt_file.getText()的toString()),你不会相信的!);
如果(transfer.getStatus()。等于(Status.cancelled)
|| transfer.getStatus()。等于(Status.refused)){
Log.d(取消,+ transfer.getError());
的System.out.println(取消!!!+ transfer.getError());
}
Log.i(transfere文件,发送文件);
Log.d(FTTRY,米英尺TRY);
btn_transfer.setText(浏览);
txt_file.setText(点击浏览n选择文件);
send_flag = TRUE;
}赶上(例外五){
Log.d(FTCATCH,米英尺抓);
btn_transfer.setText(BrowseC);
send_flag = TRUE;
}
而(!transfer.isDone()){
尝试{
视频下载(1000);
}赶上(例外五){
}
Log.i(transfere文件,发送文件状态
+ transfer.getStatus()+进步
+ transfer.getProgress());
如果(transfer.getStatus()。等于(Status.error)){
的System.out.println(ERROR !!!+ transfer.getError());
} 其他 {
的System.out.println(transfer.getStatus());
的System.out.println(transfer.getProgress());
Log.d(PROG,米英尺进展);
}
尝试{
视频下载(1000);
}赶上(例外五){
}
}
我做这个以下步骤解决同样的问题。
我使用的 asmack-2010.05.07源在Eclipse中为Android 2.2。
您可以前往asmack的ProviderManager类。更换以下code
枚举providerEnum =中ClassLoader.getResources(
/META-INF/smack.providers);
本
枚举providerEnum =中ClassLoader.getResources(
/data/smack.providers);
在此,你需要做一个补丁。在创建之前,添加下列功能新XMPPConnection
。您可以通过
配置(ProviderManager.getInstance());
这就是方法。
公共无效配置(ProviderManager的PM){
//私有数据存储
pm.addIQProvider(查询,胡言乱语:IQ:私,新PrivateDataManager.PrivateDataIQProvider());
// 时间
尝试 {
pm.addIQProvider(查询,胡言乱语:IQ:时间的Class.forName(org.jivesoftware.smackx.packet.Time));
}赶上(ClassNotFoundException异常E){
Log.w(TestClient的,无法加载类org.jivesoftware.smackx.packet.Time);
}
//名册交流
pm.addExtensionProvider(×,闲聊:X:花名册,新RosterExchangeProvider());
//消息事件
pm.addExtensionProvider(×,闲聊:X:事件,新MessageEventProvider());
//聊天状态
pm.addExtensionProvider(活性,http://jabber.org/protocol/chatstates,新ChatStateExtension.Provider());
pm.addExtensionProvider(构成,http://jabber.org/protocol/chatstates,新ChatStateExtension.Provider());
pm.addExtensionProvider(暂停,http://jabber.org/protocol/chatstates,新ChatStateExtension.Provider());
pm.addExtensionProvider(无效,http://jabber.org/protocol/chatstates,新ChatStateExtension.Provider());
pm.addExtensionProvider(水涨船高,http://jabber.org/protocol/chatstates,新ChatStateExtension.Provider());
// XHTML
pm.addExtensionProvider(HTML,http://jabber.org/protocol/xhtml-im,新XHTMLExtensionProvider());
//群聊邀请
pm.addExtensionProvider(X,胡言乱语:X:发布会,新GroupChatInvitation.Provider());
//服务发现#项目
pm.addIQProvider(查询,http://jabber.org/protocol/disco#items,新DiscoverItemsProvider());
//服务发现#信息
pm.addIQProvider(查询,http://jabber.org/protocol/disco#info,新DiscoverInfoProvider());
//数据表单
pm.addExtensionProvider(×,闲聊:X:数据,新DataFormProvider());
// MUC用户
pm.addExtensionProvider(×,http://jabber.org/protocol/muc#user,新MUCUserProvider());
// MUC管理
pm.addIQProvider(查询,http://jabber.org/protocol/muc#admin,新MUCAdminProvider());
// MUC业主
pm.addIQProvider(查询,http://jabber.org/protocol/muc#owner,新MUCOwnerProvider());
//延迟交付
pm.addExtensionProvider(X,胡言乱语:X:延时,新DelayInformationProvider());
// 版
尝试 {
pm.addIQProvider(查询,胡言乱语:IQ:版本的Class.forName(org.jivesoftware.smackx.packet.Version));
}赶上(ClassNotFoundException异常E){
//不知道这里发生了什么。
}
//电子名片
pm.addIQProvider(电子名片,名片 - 温度,新VCardProvider());
//离线消息请求
pm.addIQProvider(离线,http://jabber.org/protocol/offline,新OfflineMessageRequest.Provider());
//离线消息指示灯
pm.addExtensionProvider(离线,http://jabber.org/protocol/offline,新OfflineMessageInfo.Provider());
//最近活动
pm.addIQProvider(查询,胡言乱语:IQ:最后一个,新LastActivity.Provider());
//用户搜索
pm.addIQProvider(查询,胡言乱语:IQ:搜索,新UserSearch.Provider());
// SharedGroupsInfo
pm.addIQProvider(sharedgroup,http://www.jivesoftware.org/protocol/sharedgroup,新SharedGroupsInfo.Provider());
// JEP-33:扩展的诗节寻址
pm.addExtensionProvider(地址,http://jabber.org/protocol/address,新MultipleAddressesProvider());
// 文件传输
pm.addIQProvider(SI,http://jabber.org/protocol/si,新StreamInitiationProvider());
pm.addIQProvider(查询,http://jabber.org/protocol/bytestreams,新BytestreamsProvider());
pm.addIQProvider(打开,http://jabber.org/protocol/ibb,新IBBProviders.Open());
pm.addIQProvider(关闭,http://jabber.org/protocol/ibb,新IBBProviders.Close());
pm.addExtensionProvider(数据,http://jabber.org/protocol/ibb,新IBBProviders.Data());
// 隐私
pm.addIQProvider(查询,胡言乱语:IQ:隐私,新PrivacyProvider());
pm.addIQProvider(命令,http://jabber.org/protocol/commands,新AdHocCommandDataProvider());
pm.addExtensionProvider(畸形的行动,http://jabber.org/protocol/commands,新AdHocCommandDataProvider.MalformedActionError());
pm.addExtensionProvider(坏区域,http://jabber.org/protocol/commands,新AdHocCommandDataProvider.BadLocaleError());
pm.addExtensionProvider(坏有效载荷,http://jabber.org/protocol/commands,新AdHocCommandDataProvider.BadPayloadError());
pm.addExtensionProvider(坏的sessionid,http://jabber.org/protocol/commands,新AdHocCommandDataProvider.BadSessionIDError());
pm.addExtensionProvider(会话过期,http://jabber.org/protocol/commands,新AdHocCommandDataProvider.SessionExpiredError());
}
我从下面的链接 HTTP:/ /$c$c.google.com/p/asmack/issues/detail?id=23
This error come in log.
from='kutbi1@360degree/Smack' to='akash@360degree/Smack' type='error' id='hK1L6-5'>
<si xmlns='http://jabber.org/protocol/si' id='jsi_191216212994140179' mime-type='image/png' profile='http://jabber.org/protocol/si/profile/file-transfer'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='this_old_house.png' size='12623'>
<desc>You won't believe this!</desc></file>
<feature xmlns='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</value></option>
<option><value>http://jabber.org/protocol/ibb</value></option>
</field>
</x>
</feature>
</si>
<error code='503' type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error></iq>
I have use following code here
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(Main.connection);
if (sdm == null)
sdm = new ServiceDiscoveryManager(Main.connection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
FileTransferNegotiator.setServiceEnabled(Main.connection, true);
FileTransferManager manager = new FileTransferManager(Main.connection);
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(id
+ "/Smack");
Log.i("transfere file", "outgoingfiletransfere is created");
try{
//OutgoingFileTransfer.setResponseTimeout(60000);
transfer.sendFile(new File(txt_file.getText().toString()), "You won't believe this!");
if (transfer.getStatus().equals(Status.cancelled)
|| transfer.getStatus().equals(Status.refused)) {
Log.d("Cancel", ""+transfer.getError());
System.out.println("Cancelled!!! " + transfer.getError());
}
Log.i("transfere file", "sending file");
Log.d("FTTRY", "m in ft TRY");
btn_transfer.setText("Browse");
txt_file.setText("click on browse n Select File");
send_flag = true;
}catch (Exception e) {
Log.d("FTCATCH", "m in ft catch");
btn_transfer.setText("BrowseC");
send_flag = true;
}
while(!transfer.isDone()) {
try{
Thread.sleep(1000);
}catch (Exception e) {
}
Log.i("transfere file", "sending file status "
+ transfer.getStatus() + "progress: "
+ transfer.getProgress());
if(transfer.getStatus().equals(Status.error)) {
System.out.println("ERROR!!! " + transfer.getError());
} else {
System.out.println(transfer.getStatus());
System.out.println(transfer.getProgress());
Log.d("PROG", "m in ft progress");
}
try{
Thread.sleep(1000);
}catch (Exception e) {
}
}
I solved the same issue by doing this following procedure.
I am using asmack-2010.05.07-source in eclipse for android-2.2.
Go for ProviderManager class in the asmack. Replace the following code
Enumeration providerEnum = classLoader.getResources(
"/META-INF/smack.providers");
with this
Enumeration providerEnum = classLoader.getResources(
"/data/smack.providers");
After this you need to do a patch. Add the following function before you creating thenew XMPPConnection
. You can call this function by
configure(ProviderManager.getInstance());
This is the method.
public void configure(ProviderManager pm) {
// Private Data Storage
pm.addIQProvider("query","jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
// Time
try {
pm.addIQProvider("query","jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
} catch (ClassNotFoundException e) {
Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time");
}
// Roster Exchange
pm.addExtensionProvider("x","jabber:x:roster", new RosterExchangeProvider());
// Message Events
pm.addExtensionProvider("x","jabber:x:event", new MessageEventProvider());
// Chat State
pm.addExtensionProvider("active","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("composing","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("paused","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("inactive","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("gone","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
// XHTML
pm.addExtensionProvider("html","http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());
// Group Chat Invitations
pm.addExtensionProvider("x","jabber:x:conference", new GroupChatInvitation.Provider());
// Service Discovery # Items
pm.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
// Service Discovery # Info
pm.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Data Forms
pm.addExtensionProvider("x","jabber:x:data", new DataFormProvider());
// MUC User
pm.addExtensionProvider("x","http://jabber.org/protocol/muc#user", new MUCUserProvider());
// MUC Admin
pm.addIQProvider("query","http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
// MUC Owner
pm.addIQProvider("query","http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
// Delayed Delivery
pm.addExtensionProvider("x","jabber:x:delay", new DelayInformationProvider());
// Version
try {
pm.addIQProvider("query","jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
} catch (ClassNotFoundException e) {
// Not sure what's happening here.
}
// VCard
pm.addIQProvider("vCard","vcard-temp", new VCardProvider());
// Offline Message Requests
pm.addIQProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
pm.addExtensionProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
// Last Activity
pm.addIQProvider("query","jabber:iq:last", new LastActivity.Provider());
// User Search
pm.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
pm.addIQProvider("sharedgroup","http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
pm.addExtensionProvider("addresses","http://jabber.org/protocol/address", new MultipleAddressesProvider());
// FileTransfer
pm.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
pm.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
pm.addIQProvider("open","http://jabber.org/protocol/ibb", new IBBProviders.Open());
pm.addIQProvider("close","http://jabber.org/protocol/ibb", new IBBProviders.Close());
pm.addExtensionProvider("data","http://jabber.org/protocol/ibb", new IBBProviders.Data());
// Privacy
pm.addIQProvider("query","jabber:iq:privacy", new PrivacyProvider());
pm.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
pm.addExtensionProvider("malformed-action", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.MalformedActionError());
pm.addExtensionProvider("bad-locale", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadLocaleError());
pm.addExtensionProvider("bad-payload", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadPayloadError());
pm.addExtensionProvider("bad-sessionid", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadSessionIDError());
pm.addExtensionProvider("session-expired", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.SessionExpiredError());
}
I got the solution from the following link http://code.google.com/p/asmack/issues/detail?id=23
这篇关于使用沾染了Android应用程序的文件传输。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!