TURN Connection using the iOS XMPPFramework and an OpenFire Server

你离开我真会死。 提交于 2019-12-12 02:35:40

问题


Problem : How can I get a successful TURN Connection using the iOS XMPPFramework and an OpenFire Server. I want to be able to send and recieve files.

Note : The base of my code is from the following tutorial : http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/

Update 13th April 2012 : After more research, I think the real relevant code I need to display in this question is this ...

This is where the TURNSocket attempts to connect

XMPPJID *jid = [XMPPJID jidWithString:@"myFriendsUsername@beta.myCompany.co.uk"];

NSLog(@"Attempting TURN connection to %@", jid);

TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:jid];

[turnSockets addObject:turnSocket];

[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
[turnSocket release];

However, when I debug through the code, in TURNSocket I get to a comment which states that "We were unable to find a single proxy server from our list". This is because the Array 'streamhosts' never gets populated. What could be the issue? Is there some XML somewhere that should tell me the problem? Is the issue likely to be with OpenFire?


回答1:


The problem is caused if a full jID with a resource is not provided to TurnSocket.m! This is passed in in viewDidLoad of SMChatViewController

e.g Use

friendsUsername@beta.myCompany.co.uk/spark

rather than

friendsUsername@beta.myCompany.co.uk

My progress on this project can be followed here




回答2:


This is the class method of TURNSocket you call to populate the proxy candidates of the TURNSocket stream host. So you should put streamhost back to what it was before stream-host.

+ (void)setProxyCandidates:(NSArray *)candidates;

[TURNSocket setProxyCandidates:@["host1.somedomain.com", @"host2.someotherdomain.com"]];



回答3:


In processRequestResponse.m in TurnSocket, the name of the streamhost element wasn't what OpenFire was giving me. I have changed it from this

NSXMLElement *streamhostUsed = [query elementForName:@"streamhost-used"];

to this

NSXMLElement *streamhostUsed = [query elementForName:@"streamhost"];

However, I now have a new error which I am starting a new question for ... OpenFire/XMPP 503 service-unavailable error (XEP-0065 using iOS XMPPFramework)

Update 20/4/2012 : I now believe this answer is wrong! If it was working correctly, streamhostUsed would be there, rather than streamhost with an error!



来源:https://stackoverflow.com/questions/10123663/turn-connection-using-the-ios-xmppframework-and-an-openfire-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!