Closed taylorcressy closed 8 years ago
How embarrassing. Ignore this. Was formatting username / password with "%s" instead of "%@". invalid symbols. Which was probably causing the xmpp stream to become improperly formatted..... Fun times.
@taylorcressy Nice to know that you found your issue ;)
Hey guys. I have been banging my head against wall with this issue for the last couple of days, so now here I am.
I am attempting to connect to my Ejabberd server (16.06) with the following c2s configuration:
`listen:
The server, for now, is just on my dev machine. So I am connecting to it as localhost. Now, in my AppDelegate I initialize OneChat and specify host / port / startTLSPolicy as such:
` OneChat.start(true, delegate: self) { (stream, error) in if let _ = error { print("Error opening one chat") } else { print("Successfully opened chat") } }
In my ChatController I connect as such:
OneChat.sharedInstance.connect(username: String(format: "%s@%s", self.chatUsername!, ChatConversationsViewController.HOST), password: self.chatPassword!) { (stream, error) -> Void in if let _ = error { print("Failed to connect to XMPP server with \(self.chatUsername) and \(self.chatPassword)") let alertController = UIAlertController(title: "Sorry", message: "An error occured: \(error)", preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in //do something })) self.presentViewController(alertController, animated: true, completion: nil) } else { print("Successfully Connected") } };
Firstly, my callbacks are never called for either the OneChat.start() / OneChat.sharedInstace.connect().
Secondly, the behavior I see is that when I connect my delegate's oneStreamDidConnect() gets called and then my oneStreamDidDisconnect() get's called immediately after. The error message I receive is "Socket closed by remote peer".
I put debug logging on the Ejabberd instance and I get the following:
2016-07-21 11:20:58.297 [debug] <0.613.0>@ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?>">> 2016-07-21 11:20:58.298 [debug] <0.613.0>@ejabberd_receiver:process_data:284 Received XML on stream = <<60,115,116,114,101,97,109,58,115,116,114,101,97,109,32,120,109,108,110,115,61,39,106,97,98,98,101,114,58,99,108,105,101,110,116,39,32,120,109,108,110,115,58,115,116,114,101,97,109,61,39,104,116,116,112,58,47,47,101,116,104,101,114,120,46,106,97,98,98,101,114,46,111,114,103,47,115,116,114,101,97,109,115,39,32,118,101,114,115,105,111,110,61,39,49,46,48,39,32,116,111,61,39,32,226,128,158,226,136,158,14,1,39,62>> 2016-07-21 11:20:58.298 [debug] <0.614.0>@ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='10454082093091685755' from='localhost' version='1.0'>">> 2016-07-21 11:20:58.298 [debug] <0.614.0>@ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'></xml-not-well-formed></stream:error>">> 2016-07-21 11:20:58.298 [debug] <0.614.0>@ejabberd_c2s:send_text:1852 Send XML on stream = <<"</stream:stream>">>
I am sorry if this is an Ejabberd configuration error, but it's an "out of the box" configuration.
Thanks, tc
p.s. Excuse the formatting, I am terrible with it.