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 if swapping HTTPS protocol with HTTP #502

Open
knocte opened this issue Jan 17, 2019 · 2 comments
Open

NullReferenceException if swapping HTTPS protocol with HTTP #502

knocte opened this issue Jan 17, 2019 · 2 comments

Comments

@knocte
Copy link
Contributor

knocte commented Jan 17, 2019

Let's say you're connecting to server https://foo/bar/baz successfully with Nethereum.

One day, you decide to try a non-encrypted connection. e.g. same URL but with http: http://foo/bar/baz. If the server has this port closed or returns some reply that Nethereum doesn't expect, then Nethereum should throw an intelligible error.

However, this is the result:

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Exception: Some problem when connecting to http://etc-geth.0xinfra.com ---> System.AggregateException: One or more errors occurred. ---> Nethereum.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at Nethereum.JsonRpc.Client.RpcLogger.HasError (Nethereum.JsonRpc.Client.RpcMessages.RpcResponseMessage message) [0x00001] in <ad9c1c8d599341d5a3521687e31e522f>:0
  at Nethereum.JsonRpc.Client.RpcLogger.LogResponse (Nethereum.JsonRpc.Client.RpcMessages.RpcResponseMessage responseMessage) [0x00027] in <ad9c1c8d599341d5a3521687e31e522f>:0
  at Nethereum.JsonRpc.Client.RpcClient+<SendAsync>d__12.MoveNext () [0x00233] in <cd7f02d2e3384ecc851dd34ae2d588ad>:0
  --- End of inner exception stack trace ---
  at Nethereum.JsonRpc.Client.RpcClient+<SendAsync>d__12.MoveNext () [0x002ed] in <cd7f02d2e3384ecc851dd34ae2d588ad>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at Nethereum.JsonRpc.Client.ClientBase+<SendInnerRequestAsync>d__11`1[T].MoveNext () [0x00082] in <ad9c1c8d599341d5a3521687e31e522f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at Nethereum.JsonRpc.Client.ClientBase+<SendInnerRequestAsync>d__12`1[T].MoveNext () [0x000ae] in <ad9c1c8d599341d5a3521687e31e522f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at Nethereum.JsonRpc.Client.ClientBase+<SendRequestAsync>d__8`1[T].MoveNext () [0x0014f] in <ad9c1c8d599341d5a3521687e31e522f>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task.Wait (System.TimeSpan timeout) [0x00022] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at GWallet.Backend.Ether.Server.WaitOnTask[T,R] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg) [0x0006e] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Ether/EtherServer.fs:144
  at GWallet.Backend.Ether.Server+web3Func@268-2.Invoke (Nethereum.Web3.Web3 web3, System.String publicAddress) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Ether/EtherServer.fs:268
  at Microsoft.FSharp.Core.OptimizedClosures+Invoke@2810[T2,TResult,T1].Invoke (T2 u) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at GWallet.Backend.Ether.Server+GetUnconfirmedEtherBalance@272-2.Invoke (System.String arg10) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Ether/EtherServer.fs:272
  at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0001e] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at GWallet.Backend.Ether.Server+serverFuncs@238[T,R].Invoke (GWallet.Backend.Ether.Server+SomeWeb3 web3, T arg) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Ether/EtherServer.fs:241
  --- End of inner exception stack trace ---
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-60[E,T,R].Invoke (System.Exception _arg2) [0x000dd] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:132
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-66[E,T,R].Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:126
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@126-68[E,T,R].Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:126
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at System.Threading.Tasks.Task`1[TResult].get_Result () [0x0000f] in <4d6eb5dfe2ab4eee884ef920069afd5f>:0
  at <StartupCode$GWallet-Backend-NetStandard>.$FaultTolerantParallelClient+clo@73-51[E,R,T].Invoke (System.Threading.Tasks.Task`1[TResult] _arg1) [0x00002] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FaultTolerantParallelClient.fs:73
  at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] userCode, b result1) [0x00005] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+Bind@495-1[TResult,T].Invoke (TResult result1) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+continuation@974-1[T].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x000ad] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at GWallet.Backend.FSharpUtil.ReRaise (System.Exception ex) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/FSharpUtil.fs:20
  at GWallet.Backend.Account+GetBalanceFromServer@27-5.Invoke (System.Exception _arg2) [0x00028] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:35
  at GWallet.Backend.Account+GetBalanceFromServer@27-8.Invoke (System.Exception exn) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:27
  at GWallet.Backend.Account+GetBalanceFromServer@27-10.Invoke (System.Exception edi) [0x00000] in /Users/andres/Documents/Code/gwalletFRONTENDCLEAN/src/GWallet.Backend/Account.fs:27
  at Microsoft.FSharp.Control.AsyncPrimitives.CallFilterThenInvoke[T] (Microsoft.FSharp.Control.AsyncActivation`1[T] ctxt, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] catchFilter, System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0000c] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.AsyncPrimitives+TryWith@526[T].Invoke (System.Runtime.ExceptionServices.ExceptionDispatchInfo edi) [0x0002a] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at <StartupCode$FSharp-Core>.$Async+Execute@128.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  at Microsoft.FSharp.Control.Trampoline.Execute (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] firstAction) [0x00020] in <5b5a6dc5904cf4daa7450383c56d5a5b>:0
  --- End of inner exception stack trace ---

A NullReferenceException shouldn't be really placed in error-handling code of any app, so this should be fixed in Nethereum to provide a better exception.

@juanfranblanco
Copy link
Member

@knocte are you creating a pull for this? I guess you have done all the hard work already.

@knocte
Copy link
Contributor Author

knocte commented Feb 21, 2019

Sorry didn't have time yet.

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