having bizarre issue xamarin project working on , i'm stumped...
i use httpclient make asynchronous requests. however, app rejected app store failing meet apple's ipv6 requirements. is, request make using httpclient fails when connected through ipv6. what's bizarre fails when app started on ipv4 network switched ipv6 network. if restart application while connected ipv6 network, succeeds! also, if start app connected ipv6 switch ipv4 network, succeeds. fails when started in ipv4 switched ipv6.
it's utterly bizarre - it's httpclient caching something, create new client every request. i'm not using ip address - address, and, mentioned, works when app started connected ipv6 network. it's switch ipv4 ipv6 seems cause issue.
the code exists in pcl:
var client = new httpclient(); var urltocall = new uri("https://www.something.com/someapi/v1"); // add headers ... response = client.getasync(urltocall);
and stack trace:
trace.message": "error: connectfailure (network unreachable) @ system.net.httpwebrequest.endgetresponse (iasyncresult asyncresult) [0x00065] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/mcs/class/system/system.net/httpwebrequest.cs:946 @ system.threading.tasks.taskfactory`1[tresult].fromasynccorelogic (iasyncresult iar, system.func`2 endfunction, system.action`1 endaction, system.threading.tasks.task`1 promise, boolean requiressynchronization) <0x10019c730 + 0x0005b> in <filename unknown>:0 --- end of stack trace previous location exception thrown --- @ system.runtime.exceptionservices.exceptiondispatchinfo.throw () [0x0000c] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess (system.threading.tasks.task task) [0x0003b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:199 @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification (system.threading.tasks.task task) [0x0002e] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:170 @ system.runtime.compilerservices.taskawaiter.validateend (system.threading.tasks.task task) [0x0000b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:142 @ system.runtime.compilerservices.configuredtaskawaitable`1+configuredtaskawaiter[tresult].getresult () <0x10013ccc0 + 0x0001b> in <filename unknown>:0 @ system.net.http.httpclienthandler+<sendasync>c__async0.movenext () [0x003d6] in /library/frameworks/xamarin.ios.framework/versions/9.6.1.9/src/mono/mcs/class/system.net.http/system.net.http/httpclienthandler.cs:372 --- end of stack trace previous location exception thrown --- @ system.runtime.exceptionservices.exceptiondispatchinfo.throw () [0x0000c] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess (system.threading.tasks.task task) [0x0003b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:199 @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification (system.threading.tasks.task task) [0x0002e] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:170 @ system.runtime.compilerservices.taskawaiter.validateend (system.threading.tasks.task task) [0x0000b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:142 @ system.runtime.compilerservices.configuredtaskawaitable`1+configuredtaskawaiter[tresult].getresult () <0x10013ccc0 + 0x0001b> in <filename unknown>:0 @ system.net.http.httpclient+<sendasyncworker>c__async0.movenext () [0x000a9] in /library/frameworks/xamarin.ios.framework/versions/9.6.1.9/src/mono/mcs/class/system.net.http/system.net.http/httpclient.cs:274 --- end of stack trace previous location exception thrown --- @ system.runtime.exceptionservices.exceptiondispatchinfo.throw () [0x0000c] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess (system.threading.tasks.task task) [0x0003b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:199 @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification (system.threading.tasks.task task) [0x0002e] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:170 @ system.runtime.compilerservices.taskawaiter.validateend (system.threading.tasks.task task) [0x0000b] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/taskawaiter.cs:142 @ system.runtime.compilerservices.taskawaiter`1[tresult].getresult () <0x10013c8c0 + 0x0001b> in <filename unknown>:0 @ myapp.restclient.restservice`2+<sendhttprequest>d__10[tinput,toutput].movenext () [0x00259] in <filename unknown>:0 network unreachable @ system.net.sockets.socket.connect (system.net.endpoint remoteep) [0x000bc] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/mcs/class/system/system.net.sockets/socket.cs:1235 @ system.net.webconnection.connect (system.net.httpwebrequest request) [0x001c2] in /users/builder/data/lanes/3051/5f11db87/source/maccore/_build/library/frameworks/xamarin.ios.framework/versions/git/src/mono/mcs/class/system/system.net/webconnection.cs:213
has seen before? have idea of how fix or debug this?
in ios build settings, set httpclient implementation
use nsurlsession
.
the default continues httpclient powered httpwebrequest, while can optionally switch implementation uses ios’s, tvos's or os x's native transports (nsurlsession or cfnetwork depending on os). upside smaller binaries, , faster downloads, downside requires event loop running async operations executed.
you're using hostname, not hard-coded ipv4 ip address, news! apple reject app if you're using hard-coded ipv4 ip address.
make sure check hostname can resolve ipv6 ip address. there helpful methods in system.net.dns
can resolve ip address see if ipv6 available or not.
you can try using .maptoipv6()
extension method: link msdn documentation.
Comments
Post a Comment