I want to do a API request everytime I run the meadow. So I started using HttpClient and everything worked fine until out of nowhere I get this error:
System.Net.Http.HttpRequestException: Network subsystem is down —> System.Net.Sockets.SocketException: Network subsystem is down
Here is the full stack trace:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Network subsystem is down) ---> System.Net.Http.HttpRequestException: Network subsystem is down ---> System.Net.Sockets.SocketException: Network subsystem is down
at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Soc[21-9-2021 12:06:17] Meadow StdOut: ets.ProtocolType protocolType) <0xc1639598 + 0x0007e> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Sockets.DualSocketMultipleConnectAsync..ctor (System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) <0xc1623f78 + 0x00024> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Sockets.Socket.ConnectAsync (System.Net.Sockets.SocketType[21-9-2021 12:06:17] Meadow StdOut: socketType, System.Net.Sockets.ProtocolType protocolType, System.Net.Sockets.SocketAsyncEventArgs e) <0xc1623c38 + 0x00084> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) <0xc1618b20 + 0x0008e> in <d3a6c6c611a644b1a852e9792f1af95b>:0
--- End o[21-9-2021 12:06:17] Meadow StdOut: inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) <0xc1618b20 + 0x002d0> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16c43d8 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.H[21-9-2021 12:06:17] Meadow StdOut: tp.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0xc1615d48 + 0x00232> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.Http.HttpConnectionPool.WaitForCr[21-9-2021 12:06:17] Meadow StdOut: atedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) <0xc16e3678 + 0x0013e> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Bo[21-9-2021 12:06:17] Meadow StdOut: lean doRequestAuth, System.Threading.CancellationToken cancellationToken) <0xc15b76a8 + 0x000fa> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0xc159d178 + 0x00144> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Net.Http.HttpClient.Fin[21-9-2021 12:06:17] Meadow StdOut: shSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) <0xc16eac58 + 0x0027c> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at WifiService.Services.TPProductieService.GetToken () <0xc0ed4418 + 0x001d6> in <de2dd027f30945bf9712e13f0ac435e2>:0
--- End [21-9-2021 12:06:17] Meadow StdOut: f inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) <0xc16e9c10 + 0x00022> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) <0xc16e9410 + 0x000a0> in <843bd420d20a407aa10d62e4764eaf5d[21-9-2021 12:06:17] Meadow StdOut: :0
at System.Threading.Tasks.Task.Wait () <0xc16e9260 + 0x00018> in <843bd420d20a407aa10d62e4764eaf5d>:0
at WifiService.Services.TPProductieService..ctor () <0xc0e22a68 + 0x0000c> in <de2dd027f30945bf9712e13f0ac435e2>:0
at WifiService.MeadowApp..ctor () <0xc0835680 + 0x0000a> in <de2dd027f30945bf9712e13f0ac435e2>:0
at WifiService.Program.Main (System.String[] args) <0x[21-9-2021 12:06:17] Meadow StdOut: 0835158 + 0x00034> in <de2dd027f30945bf9712e13f0ac435e2>:0
---> (Inner Exception #0) System.Net.Http.HttpRequestException: Network subsystem is down ---> System.Net.Sockets.SocketException: Network subsystem is down
at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protoc[21-9-2021 12:06:17] Meadow StdOut: lType) <0xc1639598 + 0x0007e> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Sockets.DualSocketMultipleConnectAsync..ctor (System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) <0xc1623f78 + 0x00024> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Sockets.Socket.ConnectAsync (System.Net.Sockets.SocketType socketType, System.Net.[21-9-2021 12:06:17] Meadow StdOut: ockets.ProtocolType protocolType, System.Net.Sockets.SocketAsyncEventArgs e) <0xc1623c38 + 0x00084> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) <0xc1618b20 + 0x0008e> in <d3a6c6c611a644b1a852e9792f1af95b>:0
--- End of inner exception stack [21-9-2021 12:06:17] Meadow StdOut: race ---
at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) <0xc1618b20 + 0x002d0> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16c43d8 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.Http.HttpConnectionPool.C[21-9-2021 12:06:17] Meadow StdOut: eateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0xc1615d48 + 0x00232> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (Sy[21-9-2021 12:06:17] Meadow StdOut: tem.Threading.Tasks.ValueTask`1[TResult] creationTask) <0xc16e3678 + 0x0013e> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, Sys[21-9-2021 12:06:17] Meadow StdOut: em.Threading.CancellationToken cancellationToken) <0xc15b76a8 + 0x000fa> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0xc159d178 + 0x00144> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (Sy[21-9-2021 12:06:17] Meadow StdOut: tem.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) <0xc16eac58 + 0x0027c> in <d3a6c6c611a644b1a852e9792f1af95b>:0
at WifiService.Services.TPProductieService.GetToken () <0xc0ed4418 + 0x001d6> in <de2dd027f30945bf9712e13f0ac435e2>:0 <---
[21-9-2021 12:06:18] Meadow StdErr: [ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: On[21-9-2021 12:06:18] Meadow StdErr: e or more errors occurred. (Network subsystem is down) ---> Syst[21-9-2021 12:06:18] Meadow StdErr: em.Net.Http.HttpRequestException: Network subsystem is down --->[21-9-2021 12:06:18] Meadow StdErr: System.Net.Sockets.SocketException: Network subsystem is down
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.Socket..ctor (System.Net.Sockets.Address[21-9-2021 12:06:18] Meadow StdErr: Family addressFamily, System.Net.Sockets.SocketType socketType, [21-9-2021 12:06:18] Meadow StdErr: System.Net.Sockets.ProtocolType protocolType) <0xc1639598 + 0x00[21-9-2021 12:06:18] Meadow StdErr: 07e> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.DualSocketMultipleConnectAsync..ctor (Sy[21-9-2021 12:06:18] Meadow StdErr: stem.Net.Sockets.SocketType socketType, System.Net.Sockets.Proto[21-9-2021 12:06:18] Meadow StdErr: colType protocolType) <0xc1623f78 + 0x00024> in <4dc7c76fec8d4c3[21-9-2021 12:06:18] Meadow StdErr: 69c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.Socket.ConnectAsync (System.Net.Sockets.[21-9-2021 12:06:18] Meadow StdErr: SocketType socketType, System.Net.Sockets.ProtocolType protocolT[21-9-2021 12:06:18] Meadow StdErr: ype, System.Net.Sockets.SocketAsyncEventArgs e) <0xc1623c38 + 0x[21-9-2021 12:06:18] Meadow StdErr: 00084> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.ConnectHelper.ConnectAsync (System.String h[21-9-2021 12:06:18] Meadow StdErr: ost, System.Int32 port, System.Threading.CancellationToken cance[21-9-2021 12:06:18] Meadow StdErr: llationToken) <0xc1618b20 + 0x0008e> in <d3a6c6c611a644b1a852e97[21-9-2021 12:06:18] Meadow StdErr: 92f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: --- End of inner exception stack trace ---
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.ConnectHelper.ConnectAsync (System.String h[21-9-2021 12:06:18] Meadow StdErr: ost, System.Int32 port, System.Threading.CancellationToken cance[21-9-2021 12:06:18] Meadow StdErr: llationToken) <0xc1618b20 + 0x002d0> in <d3a6c6c611a644b1a852e97[21-9-2021 12:06:18] Meadow StdErr: 92f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16c43d8 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (S[21-9-2021 12:06:18] Meadow StdErr: ystem.Net.Http.HttpRequestMessage request, System.Threading.Canc[21-9-2021 12:06:18] Meadow StdErr: ellationToken cancellationToken) <0xc1615d48 + 0x00232> in <d3a6[21-9-2021 12:06:18] Meadow StdErr: c6c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.WaitForCreatedConnection[21-9-2021 12:06:18] Meadow StdErr: Async (System.Threading.Tasks.ValueTask`1[TResult] creationTask)[21-9-2021 12:06:18] Meadow StdErr: <0xc16e3678 + 0x0013e> in <d3a6c6c611a644b1a852e9792f1af95b>:0 [21-9-2021 12:06:18] Meadow StdErr:
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (Syst[21-9-2021 12:06:18] Meadow StdErr: em.Net.Http.HttpRequestMessage request, System.Boolean doRequest[21-9-2021 12:06:18] Meadow StdErr: Auth, System.Threading.CancellationToken cancellationToken) <0xc[21-9-2021 12:06:18] Meadow StdErr: 15b76a8 + 0x000fa> in <d3a6c6c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.[21-9-2021 12:06:18] Meadow StdErr: HttpRequestMessage request, System.Threading.CancellationToken c[21-9-2021 12:06:18] Meadow StdErr: ancellationToken) <0xc159d178 + 0x00144> in <d3a6c6c611a644b1a85[21-9-2021 12:06:18] Meadow StdErr: 2e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.[21-9-2021 12:06:18] Meadow StdErr: Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRe[21-9-2021 12:06:18] Meadow StdErr: questMessage request, System.Threading.CancellationTokenSource c[21-9-2021 12:06:18] Meadow StdErr: ts, System.Boolean disposeCts) <0xc16eac58 + 0x0027c> in <d3a6c6[21-9-2021 12:06:18] Meadow StdErr: c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at WifiService.Services.TPProductieService.GetToken () <0xc0ed[21-9-2021 12:06:18] Meadow StdErr: 4418 + 0x001d6> in <de2dd027f30945bf9712e13f0ac435e2>:0
[21-9-2021 12:06:18] Meadow StdErr: --- End of inner exception stack trace ---
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.Task.ThrowIfExceptional (System.Bool[21-9-2021 12:06:18] Meadow StdErr: ean includeTaskCanceledExceptions) <0xc16e9c10 + 0x00022> in <84[21-9-2021 12:06:18] Meadow StdErr: 3bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.Task.Wait (System.Int32 milliseconds[21-9-2021 12:06:18] Meadow StdErr: Timeout, System.Threading.CancellationToken cancellationToken) <[21-9-2021 12:06:18] Meadow StdErr: 0xc16e9410 + 0x000a0> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.Task.Wait () <0xc16e9260 + 0x00018> [21-9-2021 12:06:18] Meadow StdErr: in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at WifiService.Services.TPProductieService..ctor () <0xc0e22a6[21-9-2021 12:06:18] Meadow StdErr: 8 + 0x0000c> in <de2dd027f30945bf9712e13f0ac435e2>:0
[21-9-2021 12:06:18] Meadow StdErr: at WifiService.MeadowApp..ctor () <0xc0835680 + 0x0000a> in <d[21-9-2021 12:06:18] Meadow StdErr: e2dd027f30945bf9712e13f0ac435e2>:0
[21-9-2021 12:06:18] Meadow StdErr: at WifiService.Program.Main (System.String[] args) <0xc0835158[21-9-2021 12:06:18] Meadow StdErr: + 0x00034> in <de2dd027f30945bf9712e13f0ac435e2>:0
[21-9-2021 12:06:18] Meadow StdErr: ---> (Inner Exception #0) System.Net.Http.HttpRequestException: [21-9-2021 12:06:18] Meadow StdErr: Network subsystem is down ---> System.Net.Sockets.SocketExceptio[21-9-2021 12:06:18] Meadow StdErr: n: Network subsystem is down
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.Socket..ctor (System.Net.Sockets.Address[21-9-2021 12:06:18] Meadow StdErr: Family addressFamily, System.Net.Sockets.SocketType socketType, [21-9-2021 12:06:18] Meadow StdErr: System.Net.Sockets.ProtocolType protocolType) <0xc1639598 + 0x00[21-9-2021 12:06:18] Meadow StdErr: 07e> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.DualSocketMultipleConnectAsync..ctor (Sy[21-9-2021 12:06:18] Meadow StdErr: stem.Net.Sockets.SocketType socketType, System.Net.Sockets.Proto[21-9-2021 12:06:18] Meadow StdErr: colType protocolType) <0xc1623f78 + 0x00024> in <4dc7c76fec8d4c3[21-9-2021 12:06:18] Meadow StdErr: 69c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Sockets.Socket.ConnectAsync (System.Net.Sockets.[21-9-2021 12:06:18] Meadow StdErr: SocketType socketType, System.Net.Sockets.ProtocolType protocolT[21-9-2021 12:06:18] Meadow StdErr: ype, System.Net.Sockets.SocketAsyncEventArgs e) <0xc1623c38 + 0x[21-9-2021 12:06:18] Meadow StdErr: 00084> in <4dc7c76fec8d4c369c3e9681a0580b6a>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.ConnectHelper.ConnectAsync (System.String h[21-9-2021 12:06:18] Meadow StdErr: ost, System.Int32 port, System.Threading.CancellationToken cance[21-9-2021 12:06:18] Meadow StdErr: llationToken) <0xc1618b20 + 0x0008e> in <d3a6c6c611a644b1a852e97[21-9-2021 12:06:18] Meadow StdErr: 92f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: --- End of inner exception stack trace ---
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.ConnectHelper.ConnectAsync (System.String h[21-9-2021 12:06:18] Meadow StdErr: ost, System.Int32 port, System.Threading.CancellationToken cance[21-9-2021 12:06:18] Meadow StdErr: llationToken) <0xc1618b20 + 0x002d0> in <d3a6c6c611a644b1a852e97[21-9-2021 12:06:18] Meadow StdErr: 92f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16c43d8 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (S[21-9-2021 12:06:18] Meadow StdErr: ystem.Net.Http.HttpRequestMessage request, System.Threading.Canc[21-9-2021 12:06:18] Meadow StdErr: ellationToken cancellationToken) <0xc1615d48 + 0x00232> in <d3a6[21-9-2021 12:06:18] Meadow StdErr: c6c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.WaitForCreatedConnection[21-9-2021 12:06:18] Meadow StdErr: Async (System.Threading.Tasks.ValueTask`1[TResult] creationTask)[21-9-2021 12:06:18] Meadow StdErr: <0xc16e3678 + 0x0013e> in <d3a6c6c611a644b1a852e9792f1af95b>:0 [21-9-2021 12:06:18] Meadow StdErr:
[21-9-2021 12:06:18] Meadow StdErr: at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <[21-9-2021 12:06:18] Meadow StdErr: 0xc16e3dd0 + 0x00034> in <843bd420d20a407aa10d62e4764eaf5d>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (Syst[21-9-2021 12:06:18] Meadow StdErr: em.Net.Http.HttpRequestMessage request, System.Boolean doRequest[21-9-2021 12:06:18] Meadow StdErr: Auth, System.Threading.CancellationToken cancellationToken) <0xc[21-9-2021 12:06:18] Meadow StdErr: 15b76a8 + 0x000fa> in <d3a6c6c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.[21-9-2021 12:06:18] Meadow StdErr: HttpRequestMessage request, System.Threading.CancellationToken c[21-9-2021 12:06:18] Meadow StdErr: ancellationToken) <0xc159d178 + 0x00144> in <d3a6c6c611a644b1a85[21-9-2021 12:06:18] Meadow StdErr: 2e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.[21-9-2021 12:06:18] Meadow StdErr: Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRe[21-9-2021 12:06:18] Meadow StdErr: questMessage request, System.Threading.CancellationTokenSource c[21-9-2021 12:06:18] Meadow StdErr: ts, System.Boolean disposeCts) <0xc16eac58 + 0x0027c> in <d3a6c6[21-9-2021 12:06:18] Meadow StdErr: c611a644b1a852e9792f1af95b>:0
[21-9-2021 12:06:18] Meadow StdErr: at WifiService.Services.TPProductieService.GetToken () <0xc0ed[21-9-2021 12:06:18] Meadow StdErr: 4418 + 0x001d6> in <de2dd027f30945bf9712e13f0ac435e2>:0 <---
[21-9-2021 12:06:18] Meadow StdErr:
So I googled some stuff and I came on this post.
Which says that the Api Url shouldn’t be localhost, which I don’t have.
This is my code:
async Task GetToken()
{
var serverUri = TPServerUri + "/oauth/token";
var body = @"";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (HttpClient client = new HttpClient())
{
client.Timeout = new TimeSpan(0, 5, 0);
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri(serverUri),
Content = new StringContent(body, Encoding.UTF8, RestSharp.Serialization.ContentType.Json),
};
HttpResponseMessage response = await client.SendAsync(request).ConfigureAwait(false);
Console.WriteLine(response.ReasonPhrase);
response.EnsureSuccessStatusCode();
if (response.StatusCode == HttpStatusCode.OK)
{
Token = await response.Content.ReadAsAsync<TokenViewModel>(new[] { new JsonMediaTypeFormatter() });
}
}
}
Not sure if this has anything to do with the Meadow but can someone help me get into the right direction?