Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in Transport.TcpTransport when there is no internet connection #138

Closed
sdebruyn opened this issue Mar 8, 2019 · 3 comments

Comments

@sdebruyn
Copy link

sdebruyn commented Mar 8, 2019

I am using this library through the service bus SDK for Xamarin.Android and when I turn my internet connection off, I get an endless loop of exceptions with the following stacktrace:

{System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Azure.Amqp.Transport.TcpTransport..ctor (System.Net.Sockets.Socket socket, Microsoft.Azure.Amqp.Transport.TcpTransportSettings transportSettings) [0x0004c] in <…}

  at Microsoft.Azure.Amqp.Transport.TcpTransport..ctor (System.Net.Sockets.Socket socket, Microsoft.Azure.Amqp.Transport.TcpTransportSettings transportSettings) [0x0004c] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
  at Microsoft.Azure.Amqp.Transport.TcpTransportInitiator.Complete (System.Net.Sockets.SocketAsyncEventArgs e, System.Boolean completeSynchronously) [0x00040] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.ServiceBusConnection+<CreateConnectionAsync>d__44.MoveNext () [0x00090] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\ServiceBusConnection.cs:225 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1+<OnCreateAsync>d__6[T].MoveNext () [0x00077] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.Singleton`1+<GetOrCreateAsync>d__13[TValue].MoveNext () [0x00154] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.Singleton`1+<GetOrCreateAsync>d__13[TValue].MoveNext () [0x001fc] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Amqp.AmqpLinkCreator+<CreateAndOpenAmqpLinkAsync>d__11.MoveNext () [0x00070] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Amqp\AmqpLinkCreator.cs:41 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<CreateLinkAsync>d__101.MoveNext () [0x00188] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:1535 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1+<OnCreateAsync>d__6[T].MoveNext () [0x00077] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.Singleton`1+<GetOrCreateAsync>d__13[TValue].MoveNext () [0x00154] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Amqp.Singleton`1+<GetOrCreateAsync>d__13[TValue].MoveNext () [0x001fc] in <3b45427d81d44b4aa3f01d405febfb3f>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<OnReceiveAsync>d__86.MoveNext () [0x002c5] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:1068 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<>c__DisplayClass64_0+<<ReceiveAsync>b__0>d.MoveNext () [0x00038] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:375 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d__20.MoveNext () [0x00171] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:83 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d__20.MoveNext () [0x002bc] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:108 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<ReceiveAsync>d__64.MoveNext () [0x001e2] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:389 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<ReceiveAsync>d__62.MoveNext () [0x0002f] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:323 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.ServiceBus.MessageReceivePump+<MessagePumpTaskAsync>d__11.MoveNext () [0x000ee] in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\MessageReceivePump.cs:64 

Tested on multiple devices with different Android versions
Targeting Android API level 28

=== Visual Studio Enterprise 2019 Preview for Mac ===

Version 8.0 Preview (8.0 build 2624)
Installation UUID: e1324239-09f8-4ef0-841d-818a176fdfbd
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 5.6.0.2 (d16-0 / 040682909)

	Package version: 518000268

=== Mono Framework MDK ===

Runtime:
	Mono 5.18.0.268 (2018-08/68aad3b0eb7) (64-bit)
	Package version: 518000268

=== NuGet ===

Version: 4.8.0.5385

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.2.0
	2.1.2
	2.1.1
	2.1.0
	2.0.7
	2.0.5
SDK: /usr/local/share/dotnet/sdk/2.2.100/Sdks
SDK Versions:
	2.2.100
	2.1.302
	2.1.301
	2.1.300
	2.1.200
	2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.18.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 10.1 (14460.46)
Build 10B61

=== Xamarin.Mac ===

Version: 5.2.1.15 (Visual Studio Enterprise)
Hash: d60abd198
Branch: 
Build date: 2019-02-01 12:23:30-0500

=== Xamarin.iOS ===

Version: 12.2.1.15 (Visual Studio Enterprise)
Hash: d60abd198
Branch: d15-9
Build date: 2019-02-01 12:23:29-0500

=== Xamarin.Android ===

Version: 9.1.8.0 (Visual Studio Enterprise)
Android SDK: /Users/sam/Library/Android/sdk
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		5.0   (API level 21)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)
		8.0   (API level 26)
		8.1   (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 28.0.3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/sam/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.13
Hash: ec487ee
Branch: remotes/origin/d16-0
Build date: 2019-02-28 22:03:50 UTC

=== Xamarin Designer ===

Version: 4.17.4.366
Hash: b4b7c658d
Branch: remotes/origin/d16-0
Build date: 2019-02-18 13:35:26 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 800002624
Git revision: 2efed6c01e4a62b8adc3b048a68f792390c894a0
Build date: 2019-03-04 18:20:21+00
Build branch: master
Xamarin extensions: 6457d5033f37b53ae852bd388eed15a30c8e86eb

=== Operating System ===

Mac OS X 10.14.3
Darwin 18.2.0 Darwin Kernel Version 18.2.0
    Thu Dec 20 20:46:53 PST 2018
    root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64

@xinchen10
Copy link
Member

What is the ServiceBus package version?

@sdebruyn
Copy link
Author

Microsoft.Azure.Amqp 2.4.1
Microsoft.Azure.ServiceBus 3.1.1

@xinchen10
Copy link
Member

Based on my testing, the repeated exceptions are generated by the retry logic in the Service Bus library when connection fails. On monodroid the socket API used by the amqp library returns SocketError.Success even when there is no network connectivity. I will update the code to throw correct exception instead of a NullReferenceException.

xinchen10 added a commit that referenced this issue Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants