1

Getting error code 504 Gateway Timeout when opening more than 6 parallel NSURLConnection.sendSynchronousRequest using dispatch_group_async and different dispatch queue and dispatch group.

  • This error is not consistent and happens around 30% of the time.

  • This error is not happening when I reduce the amount of parallel connections to 5.

Does anyone now why this is happening? Isn't NSURLConnection thread safe?

CloudSails
  • 101
  • 7

1 Answers1

1

You are getting a Status 504 from the server. The problem isn't in NSURLConnection. It means that NSURLConnection has talked to the server, the server wasn't happy, and reported that error.

I would think that the server isn't able to handle too many simultaneous requests. It will probably also happen if many different devices use the server at the same time.

You need to be able to handle any error and any status that is returned appropriately. In case of Status 504, which is just an indication that the server is too busy, the proper handling would be to try the same request a few seconds later and in general not to try too many request simultaneously.

gnasher729
  • 51,477
  • 5
  • 75
  • 98