Closed Dimigergo closed 4 years ago
@mandel-macaque - Can you triage this? It's deep networking stuff.
@Dimigergo I believe I know what is the root cause of the issue. But to confirm it I need some extra information. With the error and the wireshark screenshot I believe that the following is happening:
The main issue is that due to the configuration you are using, you have not set the multiPath property. Since you have not changed that, the default behaviour is that of NSURLSessionMultipathServiceTypeNone:
The default service type indicating that Multipath TCP should not be used.
There are two different ways to solve this:
First approach is at the moment the easiest one for you to test, simple add the property BUT you have to make sure that the server side has been configured to support multipath tcp.
For the second approach, here is some information that can be useful:
The error 'Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."' means that the connection was dropped, that can happen in c# and native code, there is no relation with the bindings. If this happens, you will need to recover (catch the exception) and retry if you consider it valid. If the connection is lost you might need to create a new httpclient.
Please test the first approach and let me know how far it gets (we might have issues in the server side).
@mandel-macaque Thanks for your response!
First of all, sorry, my description is not so correct. Two main thing that I forgot to mention:
My situation is the following:
The first point, you mentioned: I have set the MultipathServiceType property to Handover, this caused error code 1004 (Could not connect to server).
I have made it (implement when exception occures, I reinitialize (new HttpClient) the connection), but the error (1005) is still alive.
I have tested it with a valid SIM card with and without wifi and the error is the same as original 1005 error.
Next Friday, I can go our office and I will try the whole test without OpenVPN.
Thanks for your advices!
Ah! the vpn does make a HUGE difference. I'll start looking into the possible causes for the VPN to be dropping the connection, that is a scenario we don't usually see, so we might find something interesting in that area. Is it possible for you to provide a small example app that I can take a look at?
There is also an other route we can take a look at. Can you try with the other handlers, the fully managed one and the CFNetwork based one? If will be interesting to see if they drop the connection or not. The implementations are completely different and would helps us to debug this (if the all are loosing the connection, we know there is something fishy with the VPN, else, something is wrong with the NSUrlSession implementation).
Of course, I try to implement these things and make an example next week, and share it with you.
Hello!
I have implemented the fully managed HttpClient in ios and its works perfect with physical device and simulator also. So for the testing, I can use this Managed HttpClient.
I have tried to use CFNetwork, but both of the simulator and the device throw HttpRequestException with InnerException: The operation couldn't be completed (OSStatus error -9806.) -> I googled it, and its a SSL handshake error, but I can't figured it out why.
With server side wireshark, there isn't any tcp pack in the output.
I have tried the
Environment.SetEnvironmentVariable("CFNETWORK_DIAGNOSTICS", "3", EnvironmentVariableTarget.Process);
In the AppDelegate.cs after LoadApplication(new App());
, but I can't find any log or Logs folder in ~/Library/Developer/CoreSimulator/Devices/[UUID]/data/Containers/Data/Application/[FOLDER_GUID]/Library
So today I can tell you only that the Managed is ok.
Thanks in advance!
Hello!
I have tried it without OpenVPN and its works well.
The overall is that only NSUrlSessionHandler with OpenVPN is raise the exception, but CFNetwork was not tested.
Is there any other test what I can make for you? Thanks in advance!
Ok, so that is a 'good step forward' we do know that the issue is the interaction between OpenVPN and NSUrlSession Handler. Is there a way you can create a small sample app that tries to do a request using the OpenVPN in the wya you are using it. Once I have that and I can reproduce it I will work to get you a fix ASAP.
PS: Sorry for the delay, got side tracked to other urgent issue :/
Hello! :)
Today I have started to write a sample app, and when I try out an api call with NSUrlSessionHandler it was working. So I tried out with my normal application, and the error went away.
I don't know why but now it works perfectly. I didn't update Xamarin nuget packages. The only thing that was happened in the past two weeks, that we had a power outage in our server park so every machine was rebooted.
So in this case, sorry that I have robbed your time.
Thanks for your collaboration!
Steps to Reproduce
My HttpClient code in Xamarin.iOS project:
Expected Behavior
The connection is established.
Actual Behavior
On the server side with wireshark only find these five rows for this connection.
The server immediately response with reset -> this is the reason with the 1005 error code.
In the server no IIS log in %SystemDrive%\inetpub\logs\LogFiles, but when I test it with simulator or Android device the IIS logs are written fine.
Environment