我有一个Xamarin.iOS应用程序-它使用https://github.com/Azure/azure-mobile-apps-net-client SDK与Azure移动服务进行通信。该应用程序支持脱机使用-一段时间内一切正常,包括脱机/在线切换数据同步等。但是,最终,它收到以下错误:System.Net.Sockets.SocketException:套接字未连接。我不知道如何从此错误中恢复。
完整的内部异常是
ex.InnerException.InnerException.InnerException {System.Net.Sockets.SocketException(0x80004005):套接字不是 连接到System.Net.Sockets.Socket.EndSend(System.IAsyncResult asyncResult)[0x00013]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:3876 在System.Net.Sockets.NetworkStream.EndWrite(System.IAsyncResult asyncResult)[0x00057]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:1043 }基础:{System.ComponentModel.Win32Exception}错误代码:10057 消息:“套接字未连接” SocketErrorCode: System.Net.Sockets.SocketError.NotConnected非公共成员:
从此异常中恢复似乎似乎无能为力。随后,它将继续在每个http调用上引发相同的异常。我正在使用Microsoft.WindowsAzure.MobileServices.MobileServiceClient
进行http呼叫以及离线表同步。捕获异常后,我创建了一个新的MobileServiceClient
实例,但这似乎无济于事。我不断收到相同的错误。
https调用引发的异常的完整堆栈跟踪如下所示:
System.Net.Http.HttpRequestException:发送时发生错误 请求---> System.Net.WebException:错误:SecureChannelFailure (无法将数据写入传输连接:套接字不 -> System.IO.IOException:无法将数据写入到 传输连接:未连接套接字。 -> System.Net.Sockets.SocketException:套接字未在以下位置连接 System.Net.Sockets.Socket.EndSend(System.IAsyncResult asyncResult) [0x00013]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:3876 在System.Net.Sockets.NetworkStream.EndWrite(System.IAsyncResult asyncResult)[0x00057]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:1043 -内部异常堆栈跟踪的结尾--在System.Net.Sockets.NetworkStream.EndWrite(System.IAsyncResult asyncResult)[0x0007c]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:1054 在System.IO.Stream + <> c.b__53_1(System.IO.Stream 流,System.IAsyncResult asyncResult)[0x00000]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/io/stream.cs:750 在 System.Threading.Tasks.TaskFactory
1+FromAsyncTrimPromise
1 [TResult,TInstance]。完成 (TInstance thisRef,System.Func`3 [T1,T2,TResult] endMethod, System.IAsyncResult asyncResult,System.Boolean requireSynchronization)[0x00000]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs:1292>
---从上一个引发异常的位置开始的堆栈结束跟踪---
在Mono.Net.Security.MobileAuthenticatedStream.InnerWrite (System.Boolean同步,System.Threading.CancellationToken cancelToken)[0x0008b]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:764 在Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancelledToken)[0x0014f]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:230 在Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancelledToken)[0x00046]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:187 在Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication处 (System.Boolean同步运行, Mono.Net.Security.MonoSslAuthenticationOptions选项, System.Threading.CancellationToken cancellingToken)[0x0024c]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:396 在Mono.Net.Security.MonoTlsStream.CreateStream (System.Net.WebConnectionTunnel隧道, System.Threading.CancellationToken cancellingToken)[0x00126]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs:129 在System.Net.WebConnection.CreateStream(System.Net.WebOperation 操作,System.Boolean重用,System.Threading.CancellationToken cancelToken)[0x00170]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/System.Net/WebConnection.cs:222 ---内部异常堆栈跟踪的结尾--- 2019-05-17 21:16:07.482 pinnacle_wh.iOS [379:49127]在System.Net.WebConnection.CreateStream (System.Net.WebOperation操作,System.Boolean重用, System.Threading.CancellationToken cancellingToken)[0x00208]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/System.Net/WebConnection.cs:234位于System.Net.WebConnection.InitConnection(System.Net .WebOperation 操作,System.Threading.CancellationToken取消令牌) [0x000f7] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/System.Net/WebConnection.cs:263,位于System.Net.WebOperation.Run()[0x00052 ]在 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/System.Net/WebOperation.cs:268 在System.Net.WebCompletionSource
1[T].WaitForCompletion () [0x00094] in <cfeb875a95684ad09f58680b02e4aa2c>:0 at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task
1 [TResult] workerTask处,System.Int32 超时,System.Action中止,System.Func1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <cfeb875a95684ad09f58680b02e4aa2c>:0 at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00019] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1200 at System.Threading.Tasks.TaskFactory
1 [TResult] .FromAsyncCoreLogic (System.IAsyncResult错误,System.Func2[T,TResult] endFunction, System.Action
1 [T] endAction,System.Threading.Tasks.Task`1 [TResult] 答应,System.Boolean requireSynchronization)[0x0000f]在 <91e0283eca55453fa9b161bf2de4edfd>:0 ---从上一个引发异常的位置开始的堆栈跟踪---在System.Net.Http.HttpClientHandler.SendAsync (System.Net.Http.HttpRequestMessage请求, System.Threading.CancellationToken cancellingToken)[0x003d3]在 /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:402 ---内部异常堆栈跟踪的结尾---位于System.Net.Http.HttpClientHandler.SendAsync (System.Net.Http.HttpRequestMessage请求, System.Threading.CancellationToken cancellingToken)[0x0046c]在 /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:406 在 PinnacleWareHouser.Helpers.AuthenticationDelegatingHandler.SendAsync (System.Net.Http.HttpRequestMessage请求, System.Threading.CancellationToken cancellingToken)[0x0019f]在 /Users/sameer/projects/PinnacleWareHouser/PinnacleWareHouser/Helpers/AuthenticationDelegatingHandler.cs:59 在System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage请求, System.Net.Http.HttpCompletionOption完成选项, System.Threading.CancellationToken cancellingToken)[0x00080]在 /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.SendRequestAsync (System.Net.Http.HttpClient客户端,System.Net.Http.HttpRequestMessage request,System.Boolean sureResponseContent, System.Threading.CancellationToken cancellingToken)[0x0007a]在 <8cb0059c34954d1285025a31cdcda32d>:0在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.RequestAsync (System.Boolean UseHandlers,System.Net.Http.HttpMethod方法, System.String uriPathAndQuery, Microsoft.WindowsAzure.MobileServices.MobileServiceUser用户, System.String内容,System.Boolean sureResponseContent, System.Collections.Generic.IDictionary
2[TKey,TValue] requestHeaders, System.Threading.CancellationToken cancellationToken) [0x000f0] in <8cb0059c34954d1285025a31cdcda32d>:0 at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.ReadAsync (System.String uriString, Microsoft.WindowsAzure.MobileServices.MobileServiceFeatures features) [0x0009c] in <8cb0059c34954d1285025a31cdcda32d>:0 2019-05-17 21:16:07.483 pinnacle_wh.iOS[379:49127] at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.ReadAsync (System.String query, System.Collections.Generic.IDictionary
2 [TKey,TValue]参数, Microsoft.WindowsAzure.MobileServices.MobileServiceFeatures功能) [0x00136]在<8cb0059c34954d1285025a31cdcda32d>:0中 Microsoft.WindowsAzure.MobileServices.Sync.PullAction.ProcessTableAsync ()[0x00134]在<8cb0059c34954d1285025a31cdcda32d>:0中 Microsoft.WindowsAzure.MobileServices.Sync.TableAction.ExecuteAsync() [0x00251]在<8cb0059c34954d1285025a31cdcda32d>:0中 Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext.ExecuteSyncAction (Microsoft.WindowsAzure.MobileServices.Sync.SyncAction操作) [0x00090]在<8cb0059c34954d1285025a31cdcda32d>:0中 Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext.PullAsync (System.String tableName, Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceTableKind tableKind,System.String queryId,System.String查询, Microsoft.WindowsAzure.MobileServices.MobileServiceRemoteTableOptions 选项,System.Collections.Generic.IDictionary2[TKey,TValue] parameters, System.Collections.Generic.IEnumerable
1 [T]相关表, Microsoft.WindowsAzure.MobileServices.MobileServiceObjectReader 阅读器,System.Threading.CancellationToken cancelledToken, Microsoft.WindowsAzure.MobileServices.Sync.PullOptions pullOptions) [0x00361]在<8cb0059c34954d1285025a31cdcda32d>:0中 PinnacleWareHouser.Clients.AzureCloudTableClient`1 [T] .PullAsync() [0x0007c]在:0处 PinnacleWareHouser.Services.AzureCloudService.PullTableAsync [T]() [0x0016a] in:0
答案 0 :(得分:0)
我认为问题是由于代码中的错误引起的。 Microsoft.WindowsAzure.MobileServices.MobileServiceClient对象实例正在Mono中收集垃圾,但底层套接字在iOS中未得到清理。