Bug 41436 - System.Net.Sockets.SocketException: The requested address is not valid in this context
Summary: System.Net.Sockets.SocketException: The requested address is not valid in thi...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Security ()
Version: unspecified
Hardware: Other Other
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2016-06-01 16:57 UTC by Jan Vilhuber
Modified: 2016-11-11 10:34 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Jan Vilhuber 2016-06-01 16:57:03 UTC
My app is getting a crash/traceback that I don't know how best to address.

*** Terminating app due to uncaught exception 'System.AggregateException: One or more errors occurred.', reason: 'System.AggregateException: One or more errors occurred. ---> System.IO.IOException: EndWrite failure ---> System.Net.Sockets.SocketException: The requested address is not valid in this context
 at System.Net.Sockets.Socket.EndSend (IAsyncResult result) <0x100a7a0f0 + 0x0008c> in <filename unknown>:0 
 at System.Net.Sockets.NetworkStream.EndWrite (IAsyncResult ar) <0x100a75380 + 0x00047> in <filename unknown>:0 
 --- End of inner exception stack trace ---
 at System.Net.Sockets.NetworkStream.EndWrite (IAsyncResult ar) <0x100a75380 + 0x00098> in <filename unknown>:0 
 at Mono.Security.Protocol.Tls.SslStreamBase.InternalWriteCallback (IAsyncResult ar) <0x100a66f10 + 0x0009f> in <filename unknown>:0 
 --- End of inner exception stack trace ---
 at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers (Boolean throwOnFirstException) <0x1008122f0 + 0x004f4> in <filename unknown>:0 
 at System.Threading.CancellationTokenSource.NotifyCancellation (Boolean throwOnFirstException) <0x100812210 + 0x000c3> in <filename unknown>:0 
 at System.Threading.CancellationTokenSource.Cancel (Boolean throwOnFirstException) <0x100811720 + 0x00053> in <filename unknown>:0 
 at System.Threading.CancellationTokenSource.Cancel () <0x1008116f0 + 0x00017> in <filename unknown>:0 
 at System.Threading.CancellationTokenSource.TimerCallbackLogic (System.Object obj) <0x1008119b0 + 0x0007b> in <filename unknown>:0 
 at System.Threading.Timer+Scheduler.TimerCB (System.Object o) <0x1008bb620 + 0x0005f> in <filename unknown>:0 
 at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x10082ccf0 + 0x0002f> in <filename unknown>:0 
 at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x10082b260 + 0x001df> in <filename unknown>:0 
 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x10082cbc0 + 0x0000b> in <filename unknown>:0 
---> (Inner Exception #0) System.IO.IOException: EndWrite failure ---> System.Net.Sockets.SocketException: The requested address is not valid in this context
 at System.Net.Sockets.Socket.EndSend (IAsyncResult result) <0x100a7a0f0 + 0x0008c> in <filename unknown>:0 
 at System.Net.Sockets.NetworkStream.EndWrite (IAsyncResult ar) <0x100a75380 + 0x00047> in <filename unknown>:0 
 --- End of inner exception stack trace ---
 at System.Net.Sockets.NetworkStream.EndWrite (IAsyncResult ar) <0x100a75380 + 0x00098> in <filename unknown>:0 
 at Mono.Security.Protocol.Tls.SslStreamBase.InternalWriteCallback (IAsyncResult ar) <0x100a66f10 + 0x0009f> in <filename unknown>:0 <---

My guess is that some TLS connection was active when the device lost connectivity, and when it woke up, it got the SocketException.
Comment 1 Martin Baulig 2016-11-11 10:34:32 UTC
Do you still have this problem - and if you do, could you please provide us with a reproducible test case?