Unable to reconnect after disconnect since parser optimization #80

Closed
binarybucks opened this Issue Jul 19, 2012 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

binarybucks commented Jul 19, 2012

Since commit b793e60 I am unable to connect again once the xmppStream has been disconnected.

Steps to reproduce for me (Any version since commit b793e60):

  • Call [self xmppStream] connect:&error]
  • Wait until connection and authentication succeeded
  • Call [self xmppStream] disconnect]
  • Wait until xmppStreamDidDisconnect notification is received
  • Call [self xmppStream] connect:&error] again
  • Watch sendOpeningNegotiation: sending the two initial opening elements SEND: <?xml version='1.0'?>
    SEND: <stream:stream xmlns='jabber:client' xmlns:stream='[...]' version='1.0' to='example.com'>

What should happen next: The stream should handle the response send by the server

What happens instead: Everything just hangs there until the server closes the connection as no response is send by the client, resulting in a Socket closed by remote peer

After some debugging I think the server response is received but something in that specific commit broke the parser or something that comes afterwards.

same here

To help in the debugging:
I found out that when the parser parses the data the delegate is not valid here:

- (void)parseData:(NSData *)data
{
dispatch_block_t block = ^{ @autoreleasepool {

    int result = xmlParseChunk(parserCtxt, (const char *)[data bytes], (int)[data length], 0);

    if (result == 0)
    {
        if (delegateQueue && [delegate respondsToSelector:@selector(xmppParserDidParseData:)])    <--------

So xmppParserDidParseData is not called and everything goes wrong.
I'm cant find why is the delegate being lost.

Ok I fixed it!

in XMPPStream.m go to line 2688 and replace this:

   parser = [[XMPPParser alloc] initWithDelegate:self delegateQueue:NULL];

by:

    parser = [[XMPPParser alloc] initWithDelegate:self delegateQueue:xmppQueue];
Owner

robbiehanson commented Aug 1, 2012

@jonasman Nice catch!

davidchiles pushed a commit to davidchiles/XMPPFramework that referenced this issue Jan 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment