0

So, this issue is so hard to describe in short and I feel I should ask here first before raise an issue in AFNetworking github. Here's the story:

// Definition for words in the story.

Characters:
- APP: Our iOS app, which POST requests to a URL's API (has user input from a UITextField)
       APP's networking connection using framework AFNetworking 3.0
- DEV: Us developers, who created the iOS app.
- CUST: The troublesome customer, who live far from DEV.
        CUST used app before, then one day it doesn't work anymore (S1 has died).

Server:
- S1: The CUST's primary server (died for some reasons). This has the IP address = ip1
- S2: The CUST's secondary server (works fine). This has the IP address = ip2
- URL: The domain URL point to both server (using load balancing or something like that, I dunno).

// End-of-definition

Story begin:

CUST use app, enter URL, connection failed. CUST enter URL in iPad's browser, access normally. CUST ask DEV to check what happened. DEV enter URL in app, connect normally. At that time, DEV doesn't know that CUST has 2 servers.

Both CUST & DEV feel desperate, struggling for quite some times. CUST tried everything he can (used https / http, add / remove www, delete app and re-install). DEV got distract by unreasonable reasons (connector's error, api's error...). Then CUST remember that he's got 2 servers. CUST shared the IP addresses for DEV to check. That's when DEV find out that S1 has died but S2 hasn't.

So, DEV got the reason why CUST can't access to the URL using APP: the S1 has died. However, here's the real question for SO:

Why does it work in our end, but not in the CUST's end? Why APP (in DEV's hand) go to S2 but in CUST's hand, it go to S1 (and died)? But why CUST access URL using iPad's browser normally?

Does it has anything to do with DNS? VPN? Load balancing? I'd love to have a reason for this issue.

Thanks for reading. Feel free to edit this question, since I've also struggled to describe this as simple as possible.

UPDATE 1:

As James Jayson ask for how APP connect to URL, it use AFNetworking 3.0 with AFHTTPSessionManager with some setup:

self.sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseUrl sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
self.sessionManager.securityPolicy.allowInvalidCertificates = YES;
self.sessionManager.securityPolicy.validatesDomainName = NO;
self.sessionManager.requestSerializer.timeoutInterval = timeout;
self.sessionManager.requestSerializer = [AFJSONRequestSerializer serializer];

// Call API:
[self.sessionManager POST:path parameters:dictParams progress:nil success:^(NSURLSessionTask *task, id responseObject) { 
    // success block
} failure:^(NSURLSessionTask *task, NSError *error) {
    // failure block
}

UPDATE 2:

So, now I've got something new: CUST is using iOS 9.3.5, and DEV using iOS 10.x. DEV try to debug on iOS 9.3.5 device, CUST's error appear, error message be like this (almost the same, different with URL only).

LOG: Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSErrorFailingURLStringKey=APIURL, _kCFStreamErrorCodeKey=-2200, NSErrorFailingURLKey=APIURL, NSLocalizedDescription=Could not connect to the server., _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x16146990 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorDomainKey=4, NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bb253ce7160000000000000000}, _kCFStreamErrorCodeKey=-2200}}}

Now DEV is struggling with how to deal with this error. Please help.

Community
  • 1
  • 1
Eddie
  • 1,903
  • 2
  • 21
  • 46

1 Answers1

0

Without knowing what the app is and how it works, I am guessing it is state-full and could be due to a session that was alive on the current dead server, the dev who starts a session is directed to server 2 via the load balancer.

James Jayson
  • 336
  • 1
  • 7
  • But the `CUST` even delete the app and install it again. Does the state-full thing keep something like that even after delete? – Eddie Jan 11 '17 at 18:49
  • Yet again without knowing how the app connects, if it uses a browser to connect then the browser may remember the session, however this should not still be occurring after 30 mins due to the session expiring after a configured amount of time (usually 30 mins by default) – James Jayson Jan 11 '17 at 19:03
  • What do you want to know about how the app connect? I can share something. It normally post a request to a URL and get response back. Also, the browser got to the correct server `S2`, so shouldn't the app go to `S2` as well? – Eddie Jan 11 '17 at 19:14
  • The part that I would asking about is how the app sends the url, if it sends the url via a browser then the browser would remember even after the app is removed. the dev using the browser would not have this problem as his session would start after the first server went down so he would remain connected to server 2 even if server 1 came back online. just to be absolutely clear this is the only idea I have and could be wrong but it is a possibility. – James Jayson Jan 11 '17 at 19:21
  • The App Request to `URL` using `AFNetworking 3.0`, via @SEL `AFHTTPSessionManager POST:parameters:progress:success:failure:`. Just as simple as that. I'll update the question about that part. – Eddie Jan 11 '17 at 19:51
  • It would seem that what I was saying about a session keeping a connection pointed to that server is not the case then, best of luck with this issue! – James Jayson Jan 11 '17 at 20:01