fork download
  1. using System;
  2. using System.Linq;
  3. using System.Net.WebSockets;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. ReceiveJson().Wait();
  15. Console.ReadLine();
  16. }
  17.  
  18. static async Task ReceiveJson()
  19. {
  20. var cts = new CancellationTokenSource();
  21. var cws = new ClientWebSocket();
  22. await cws.ConnectAsync(new Uri(""), cts.Token);
  23.  
  24. var buf = new ArraySegment<byte>(new byte[8192]);
  25. await cws.ReceiveAsync(buf, cts.Token);
  26. Console.WriteLine(Encoding.UTF8.GetString(buf.ToArray()));
  27. }
  28. }
  29. }
  30.  
Runtime error #stdin #stdout #stderr 0.02s 138496KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.AggregateException: One or more errors occurred. ---> System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x00090] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at System.Uri..ctor (System.String uriString) [0x00017] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at ConsoleApplication.Program+<ReceiveJson>c__async0.MoveNext () [0x0003b] in <60583f03213e4985a03344b683779878>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00052] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at ConsoleApplication.Program.Main (System.String[] args) [0x00005] in <60583f03213e4985a03344b683779878>:0 
---> (Inner Exception #0) System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x00090] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at System.Uri..ctor (System.String uriString) [0x00017] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at ConsoleApplication.Program+<ReceiveJson>c__async0.MoveNext () [0x0003b] in <60583f03213e4985a03344b683779878>:0 <---

[ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x00090] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at System.Uri..ctor (System.String uriString) [0x00017] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at ConsoleApplication.Program+<ReceiveJson>c__async0.MoveNext () [0x0003b] in <60583f03213e4985a03344b683779878>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00052] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at ConsoleApplication.Program.Main (System.String[] args) [0x00005] in <60583f03213e4985a03344b683779878>:0 
---> (Inner Exception #0) System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x00090] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at System.Uri..ctor (System.String uriString) [0x00017] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at ConsoleApplication.Program+<ReceiveJson>c__async0.MoveNext () [0x0003b] in <60583f03213e4985a03344b683779878>:0 <---