Hi everyone,
I am developing a cross platform mobile app, whenever I sent my app to release on Apple's App Store, my app is rejected because of connection problem. I detect the problem and it is caused by my rest api. To connect my server, there are fields that take server ip and port number, and I use these inputs to create query. After click login button, query is generated and system is tried to connect to the server, but main problem here is that, first connection attempt is not happened. When I run both server and client sides in debug mode, my request do not recieve to the server side. This happens only if app is installed to new device (if app is not installed before that device). If I relaunch app after closing it, connection is established and everything works as expected.
I use try catch block to get what is the error message but the problem never happen on my device and iphone/android emulators. Here is the codes both client and server side.
Client:
public async Task getData()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");DataModel model = new DataModel();string addr = "http://" + txtServer.Text + ":" + txtPort.Text + "/Service/api/test/getData";
var response = await client.PostAsync(addr, new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); var result = await response.Content.ReadAsStringAsync(); var res = JsonConvert.DeserializeObject<ResultStruct>(result); return JsonConvert.DeserializeObject<DataModel> (res.Data.ToString()); }
Server:
[HttpPost]
[Route("getData")]
public ResultStruct getData()
{
ResultStruct result = new ResultStruct();
result.Result = true;
try
{
result.Data = getDataFromDB();
result.Message = "Success";
}
catch (Exception ex)
{
result.Result = false;
result.Message = ex.Message;
}
return result;
}
Posts
I'm using the HttpClient in a similar way, and its working fine for me..
You're definitely seeing a client side error, if the request never leaves the phone.
what is the exact rejection message from Apple in your iTunes Connect?
They said:
The "displayed an error message" is showed by me when code is entered catch part, but I do not show the exception message directly on the message, I only display "Error occured, please try again." message. I uploaded a new version which shows exception message directly on the display error.
Oh ok, that rejection message indicates something different. That's their IPv6 rejection letter.
you need to make sure that your server is setup to support IPv6 (https://developer.apple.com/support/ipv6/)
This jumped out at me from their docs:
Then they tell you how to turn off WWAN.
So you'll need to turn off WWAN and test on your device/simulator to reproduce their test. Then, if you set a breakpoint in your try/catch, and drill down to the inner exception it may tell you a little more details.
Test the app exactly the way they're testing and see what you come up with.
More info on IPv6, and why Apple is now enforcing it:
https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1
Thank you so much, I will check my server's settings. By the way, they approved my app in the past and that is why I think my server (IIS 10) supports what they want.
Hi again,
The error occurred on Apple side is "An error occurred while sending the request". This is the message of exception. Do you have any idea about this?