Forum Xamarin.iOS

NSUrlSessionHandler failing after update to Xamarin 6.2

TedRogersTedRogers USMember ✭✭✭✭
edited February 2017 in Xamarin.iOS

I am connecting to a web service via a local network IP address with HTTP scheme.

I was explicitly providing NSUrlSessionHandler to my HttpClient.

I have NSAppTransportSecurity with NSAllowLocalNetworking to YES and NSAllowsArbitraryLoads to YES. Probably don't need both but that is current setting.

Once I updated Xamarin Studio to 6.2, I can no longer connect to my web service via NSUrlSessionHandler.

I have switched for the time being to HttpClientHandler and all works and the plan is to switch eventually to HTTPS, so I should be able to switch back to NSUrlSessionHandler.

For my own understanding, I am wondering the details of what changed to alter the behavior?

Posts

  • TedRogersTedRogers USMember ✭✭✭✭

    Hey all, starting to wonder whether this is a Xamarin issue. I am trying to connect to an IP address and have NSAllowsLocalNetworking to YES. This worked prior to my update to Xamarin 6.2. I don't see the typical SSL errors in the log I expect to see with ATS errors.

    Any ideas?

    I guess I will have to create an Swift test app to try unless there are some other ideas.

  • TedRogersTedRogers USMember ✭✭✭✭
    edited March 2017

    Here is the log information I am seeing. I can't really tell whether this is an ATS issue or not from the logs.

    Does anybody know?

    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libxamarin-debug.dylib)[404] :
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(CFNetwork)[404] : TIC TCP Conn Start [7:0x174191c60]
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_endpoint_handler_start [7 10.35.32.237:65453 initial path (null)]
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 initial path (null)] reported event path:start
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 waiting path (satisfied)] reported event path:satisfied
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 waiting path (satisfied)] skipping state update
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 in_progress socket-flow (satisfied)] reported event flow:start_connect
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_endpoint_flow_protocol_connected [7 10.35.32.237:65453 in_progress socket-flow (satisfied)] Output protocol connected
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_endpoint_flow_connected_path_change [7 10.35.32.237:65453 ready socket-flow (satisfied)] Connected path is satisfied
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 ready socket-flow (satisfied)] reported event flow:finish_connect
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_connection_endpoint_report [7 10.35.32.237:65453 ready socket-flow (satisfied)] reported event flow:changed_viability
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(CFNetwork)[404] : TIC TCP Conn Event [7:0x174191c60]: 1 Err(0)
    Mar 8 10:10:28 Teds-iPhone TheApp.iOS(CFNetwork)[404] : TIC TCP Conn Connected [7:0x174191c60]: Err(0)

    1 seconds later when the request times out:

    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(libxamarin-debug.dylib)[404] :
    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(CFNetwork)[404] : TIC TCP Conn Cancel [7:0x174191c60]
    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(CFNetwork)[404] : NSURLSessionTask finished with error - code: -999
    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(CFNetwork)[404] : TIC TCP Conn Destroyed [7:0x174191c60]
    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_endpoint_handler_cancel [7 10.35.32.237:65453 ready socket-flow (satisfied)]
    Mar 8 10:10:38 Teds-iPhone TheApp.iOS(libsystem_network.dylib)[404] : nw_endpoint_flow_protocol_disconnected [7 10.35.32.237:65453 cancelled socket-flow (null)] Output protocol disconnected

  • TedRogersTedRogers USMember ✭✭✭✭
    edited March 2017

    I just wrote a test app in Swift and it works fine accessing my web service via IP address using NSUrlSession;

    Something must have changed in Xamarin 6.2 with NSUrlSessionHandler so it no longer works with ip addresses.

    Can somebody at Xamarin help here? Do I need to be using NSUrlSessionHandler differently?

  • TedRogersTedRogers USMember ✭✭✭✭

    A little more info. I am seeing two symptoms:

    1. The web service does not receive my post body
    2. The request times out
  • This is so disappointing. One of our live app stopped working after the update. We were using HttpClient with NSUrlSessionHandler previously published in Jan and it was working just fine. A couple of days back we did a minor update to the app and just stopped working. On investigation, we found out that using simple HttpClient without explicit handlers works now with TLS 1.2 so we are now using that on iOS.

  • TedRogersTedRogers USMember ✭✭✭✭

    @AsadullahYousuf What are you project settings? I think when you don't specify a handler it selects a handler based on your project settings.

  • TedRogersTedRogers USMember ✭✭✭✭

    This was resolved by latest stable build.

Sign In or Register to comment.