Https SSLRead挂起,然后返回,读取的字节数为零

Https SSLRead挂起,然后返回,读取的字节数为零,https,freeze,secure-transport,Https,Freeze,Secure Transport,我正在使用SecureTransport通过HTTPS与Google Places API通信。但是,当我读取响应时,中间的某个地方,SSLRead例程首先挂起几分钟,然后它以零字节读取返回,因此留给我一个不完整的响应。可能是什么 do { if (httpResponseBodyContentLength > -1 && offset_recv >= httpResponseBodyContentLength) { break; }

我正在使用SecureTransport通过HTTPS与Google Places API通信。但是,当我读取响应时,中间的某个地方,SSLRead例程首先挂起几分钟,然后它以零字节读取返回,因此留给我一个不完整的响应。可能是什么

do {
    if (httpResponseBodyContentLength > -1 && offset_recv >= httpResponseBodyContentLength) {
        break;
    }

    size_t bytes_available;
    for (int try = 0; try < 30; try++) {
        if ((ssl_status = SSLGetBufferedReadSize(ssl_context, &bytes_available)) != 0) {
            NetDebugLog(@"%@", [NSError errorWithDomain:NSOSStatusErrorDomain code:ssl_status userInfo:nil]);
            bytes_available = 0;
            @try {
                usleep(30000);
            }
            @catch (NSException *exception) {
                NetDebugLog(@"%@", exception);
            }
        }
        else if (bytes_available == 0) {
            @try {
                usleep(30000);
            }
            @catch (NSException *exception) {
                NetDebugLog(@"%@", exception);
            }
        }
        else {
            break;
        }
    }
    ssl_status = SSLRead(ssl_context, responseBodyBuffer + offset_recv, MIN(responseBodyBufferLength - offset_recv, bytes_available), &bytes_recv_size_t);
    bytes_recv_int = bytes_recv_size_t;
    NetDebugLog(@"SSLRead() body: %zd bytes of %zd length (%ld offset)", bytes_recv_size_t, MIN(responseBodyBufferLength - offset_recv, bytes_available), offset_recv);

    if (ssl_status != 0) {
        NSError *ssl_error = [NSError errorWithDomain:NSOSStatusErrorDomain code:ssl_status userInfo:nil];
        NetDebugLog(@"%@", ssl_error);
    }

    [responseBufferNSMutableData appendBytes:responseBodyBuffer + offset_recv length:bytes_recv_int];

    responseBodyTotalLength += bytes_recv_int;
    offset_recv += bytes_recv_int;

    if (ssl_status == -36) {
        @throw [NSException exceptionWithName:@"NAExtensions"
                                       reason:[[NSString alloc]initWithFormat:@"SSLRead() failed: %ld", bytes_recv_size_t]
                                     userInfo:nil];
    }
    else if (offset_recv == responseBodyBufferLength) {
        offset_recv = 0;
    }
}
while (bytes_recv_int > 0);
do{
如果(httpResponseBodyContentLength>-1&&offset\u recv>=httpResponseBodyContentLength){
打破
}
大小\u t字节\u可用;
for(int try=0;try<30;try++){
如果((ssl_状态=SSLGetBufferedReadSize(ssl_上下文和字节可用))!=0){
NetDebugLog(@“%@,[NSErrorWithDomain:NSOSStatusErrorDomain代码:ssl_状态用户信息:nil]);
可用字节数=0;
@试一试{
美国LEEP(30000);
}
@捕获(NSException*异常){
NetDebugLog(@“%@”,异常);
}
}
else if(可用字节数==0){
@试一试{
美国LEEP(30000);
}
@捕获(NSException*异常){
NetDebugLog(@“%@”,异常);
}
}
否则{
打破
}
}
ssl\u status=SSLRead(ssl\u上下文,responseBodyBuffer+offset\u recv,MIN(responseBodyBufferLength-offset\u recv,bytes\u可用)和bytes\u recv\u size\t);
bytes_recv_int=bytes_recv_size\t;
NetDebugLog(@“SSLRead()正文:%zd字节,长度为%zd(%ld offset)”,字节\u recv\u大小\u t,分钟(responseBodyBufferLength-offset\u recv,可用字节),偏移量\u recv);
如果(ssl_状态!=0){
NSError*ssl_error=[NSError errorWithDomain:NSOSStatusErrorDomain代码:ssl_状态用户信息:nil];
NetDebugLog(@“%@”,ssl_错误);
}
[responseBufferNSMutableData appendBytes:ResponseBuddyBuffer+偏移量记录长度:字节记录长度];
responseBodyTotalLength+=字节数;
偏移量=字节数;
如果(ssl_状态==-36){
@抛出名为@“NAExtensions”的[N异常异常
原因:[[NSString alloc]initWithFormat:@“SSLRead()失败:%ld”,字节数
用户信息:无];
}
else if(offset_recv==responseBodyBufferLength){
偏移量_recv=0;
}
}
而(字节数>0);