0

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?

Andy A
  • 4,191
  • 7
  • 38
  • 56

3 Answers3

0

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

Community
  • 1
  • 1
Andy A
  • 4,191
  • 7
  • 38
  • 56
0

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"]];
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
-1

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!

Community
  • 1
  • 1
Andy A
  • 4,191
  • 7
  • 38
  • 56
  • I tried out this, but streamhost xml elements never gets populated as result, turnsocked failed.!!! :(. I guess, streamhost-used to streamhost never get resolve. – Splendid Apr 18 '12 at 10:04
  • Mmm. If you debug through your code at this point, you may see the streamhost get populated. However, Im currently doubting my answer is correct. Im now reading through http://xmpp.org/extensions/xep-0065.html as I debug through the code to gain a deeper understanding what is happening. – Andy A Apr 18 '12 at 10:16
  • I was wondered to see when i saw your results for this question. Instead of streamhost, we shud likely to see streamhost-used xml logs inside the code logs. I had also seen how our xml logs shud look like when the turn socket success – Splendid Apr 19 '12 at 09:07