Bug 13071 - Cannot connect to the debugger
Summary: Cannot connect to the debugger
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Debugger ()
Version: 4.6.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Joaquin Jares
URL:
Depends on:
Blocks:
 
Reported: 2013-07-05 12:00 UTC by Goncalo Oliveira
Modified: 2017-05-22 18:15 UTC (History)
6 users (show)

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


Attachments
Logcat from Case #46622 (56.81 KB, application/octet-stream)
2013-09-24 11:50 UTC, Allie Miller
Details
Test Case from Case #46622 (1.63 MB, application/x-rar-compressed)
2013-09-24 11:51 UTC, Allie Miller
Details
Trace Log from Case #46622 (68.42 KB, application/octet-stream)
2013-09-24 11:52 UTC, Allie Miller
Details


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 Developer Community or GitHub 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 FIXED

Description Goncalo Oliveira 2013-07-05 12:00:15 UTC
The debugger continues to be too unstable. In fact, not just the debugger, but the link to the device itself.

I get this error 20 times a day... it's pretty inconvenient...

Couldn't connect to logcat, GetProcessId returned: 0
Mono.Android.VisualStudio.MonoAndroidPackage Error: 0 : MonoAndroidDebuggerSession
Mono.Debugging.Soft.ConnectionException: Could not connect to the debugger. ---> Mono.Debugger.Soft.VMDisconnectedException: Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown.

Server stack trace: 
   at Mono.Debugger.Soft.Connection.SendReceive(CommandSet command_set, Int32 command, PacketWriter packet)
   at Mono.Debugger.Soft.Connection.VM_GetVersion()
   at Mono.Debugger.Soft.Connection.Connect()
   at Mono.Debugger.Soft.VirtualMachine.connect()
   at Mono.Debugger.Soft.VirtualMachineManager.Connect(Connection transport, StreamReader standardOutput, StreamReader standardError)
   at Mono.Debugger.Soft.VirtualMachineManager.ConnectInternal(Socket dbg_sock, Socket con_sock, IPEndPoint dbg_ep, IPEndPoint con_ep)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
   at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
   at Mono.Debugger.Soft.VirtualMachineManager.ConnectCallback.EndInvoke(IAsyncResult result)
   at Mono.Debugger.Soft.VirtualMachineManager.EndConnect(IAsyncResult asyncResult)
   at Mono.Debugging.Soft.SoftDebuggerSession.<>c__DisplayClass9.<StartConnecting>b__8(IAsyncResult ar)
   --- End of inner exception stack trace ---
Mono.AndroidTools.AndroidLogger Error: 0 : [E:]:                     Error in device tracker
System.AggregateException: One or more errors occurred. ---> Mono.AndroidTools.AdbException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at Mono.AndroidTools.Adb.ReadFullAsyncResult.EndRead(IAsyncResult ar)
   at Mono.AndroidTools.Adb.AdbClient.ReadStringWithLength_OnReadLength(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
   at Mono.AndroidTools.Adb.AdbClient.EndReadStringWithLength(IAsyncResult asyncResult)
   at Mono.AndroidTools.TrackDeviceTask.GotString(IAsyncResult r)
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Mono.AndroidTools.AdbException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at Mono.AndroidTools.Adb.ReadFullAsyncResult.EndRead(IAsyncResult ar)
   at Mono.AndroidTools.Adb.AdbClient.ReadStringWithLength_OnReadLength(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
   at Mono.AndroidTools.Adb.AdbClient.EndReadStringWithLength(IAsyncResult asyncResult)
   at Mono.AndroidTools.TrackDeviceTask.GotString(IAsyncResult r)<---


They become more frequent when debugging and a crash occurs, though, it happens frequently. Many times, just deploying an app to the device a few times disconnects the link from the device. I have to close Visual Studio, remove cable from device, insert cable again and restart Visual Studio to be able to re-deploy.

It could be a buggy device (I do have a Samsung that is constantly breaking links, even with Android Monitor), but this is not the case. Android Studio, Eclipse and Android Monitor maintain the link.

Microsoft Visual Studio Premium 2012
Version 11.0.60610.01 Update 3
Microsoft .NET Framework
Version 4.5.50709

Installed Version: Premium

Visual C# 2012   04941-004-0043007-02975
Microsoft Visual C# 2012

Xamarin.Android   4.6.08007 (0cc7ae3b)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   1.1.200 (7d63692c)
Visual Studio extension to enable development for Xamarin.iOS
Comment 1 Goncalo Oliveira 2013-07-05 12:04:03 UTC
Having more than one instance of Visual Studio open (both with Android projects) also seem to increase the error throwing probability.
Comment 3 Allie Miller 2013-09-24 11:50:45 UTC
Created attachment 4976 [details]
Logcat from Case #46622
Comment 4 Allie Miller 2013-09-24 11:51:38 UTC
Created attachment 4977 [details]
Test Case from Case #46622
Comment 5 Allie Miller 2013-09-24 11:52:23 UTC
Created attachment 4978 [details]
Trace Log from Case #46622
Comment 6 Collin Rusk 2014-06-11 08:00:25 UTC
I'm using Visual 2010 Version 10.0.40219.1 SP1Rel.  While attempting to an application to run on my android 4.1 phone, I decided to first to attempt to debug the template application. Thus far I have been unable to do so.  The debugger closes down before the first breakpoint is reached.  The devenv log has been producing this error message consistently:

Mono.AndroidTools.AndroidLogger Error: 0 : [2014-06-10 15:17:57.4] [E:]:                     Error in device tracker
Mono.AndroidTools.AdbException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at Mono.AndroidTools.Adb.ReadFullAsyncResult.EndRead(IAsyncResult ar)
   at Mono.AndroidTools.Adb.AdbClient.ReadStringWithLength_OnReadLength(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token)
   at Mono.AndroidTools.Adb.AdbClient.EndReadStringWithLength(IAsyncResult asyncResult)
   at Mono.AndroidTools.TrackDeviceTask.GotString(IAsyncResult r)
Comment 8 Joaquin Jares 2017-05-22 18:15:29 UTC
This is not a repro anymore. Marking as Fixed for verification.