سؤال

I'm trying to implement the XMPPFramework by robbiehanson. The problem is, that I get the following error message:

Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo=0x9517440 {NSLocalizedDescription=Socket closed by remote peer}

I already tried everything I could find on the internet (XMPPPing etc.) but nothing could fix my problem. Here is the code I'm using:

- (void)connect {
    stream = [[XMPPStream alloc] init];
    [stream setEnableBackgroundingSocket:YES];
    [stream addDelegate:self delegateQueue:dispatch_get_main_queue()];

    reconnect = [[XMPPReconnect alloc] init];
    [reconnect activate:stream];

    [stream setHostName:_hostName];
    [stream setPort:5223];

    [stream setMyJID:[XMPPJID jidWithString:_username];

    NSError *e;
    if(![stream connectWithTimeout:20 error:&e]) {
        NSLog(@"%@", e);
    }

    - (void)xmppStreamDidConnect:(XMPPStream *)sender {
        NSError *e;
        [sender authenticateWithPassword:_password];

        if(e) {
            NSLog(@"%@", e);
        }
    }

I'm getting this error message immediately, not after several seconds. I already thought it might be, because our server requires SSL, but the only solution I found for SSL was running [stream secureConnection:nil]; and this only works if connected.

I also never get the -xmppStreamDidConnect: delegate method.

هل كانت مفيدة؟

المحلول

stream oldSchoolSecureConnectWithTimeout: will connect to 5223/SSL

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top