Gcobani Mkontwana

Gcobani Mkontwana

  • 565
  • 1.9k
  • 404.5k

System.Net.Sockets.SocketException

Sep 10 2019 6:01 AM
Hi Team
 
I am trying to readmessage2device, each time want to readmessage2device, i often get this websocket exception.
 
This method it does the following for running;
  1. private static async Task Main(string[] args)  
  2. {  
  3. Console.WriteLine("IoT Hub App - Read device to cloud messages.");  
  4. var connectionString = new EventHubsConnectionStringBuilder(new Uri(s_eventHubsCompatibleEndpoint), s_eventHubsCompatiblePath, s_iotHubSasKeyName, s_iotHubSasKey);  
  5. s_eventHubClient = EventHubClient.CreateFromConnectionString(connectionString.ToString());  
  6. var runtimeInfo = await s_eventHubClient.GetRuntimeInformationAsync();  
  7. var d2Partitions = runtimeInfo.PartitionIds;  
  8. CancellationTokenSource cts = new CancellationTokenSource();  
  9. Console.CancelKeyPress += (s, e) =>  
  10. {  
  11. e.Cancel = true;  
  12. cts.Cancel();  
  13. Console.WriteLine("Exiting...");  
  14. };  
  15. var tasks = new List<Task>();  
  16. foreach(string partition in d2Partitions)  
  17. {  
  18. tasks.Add(ReceiveMessagesFromDeviceAsync(partition, cts.Token));  
  19. }  
  20. Task.WaitAll(tasks.ToArray());  
  21. }  
  22. }  

What could be the reason for this? Firewall issue or network, cant seem to understand where its getting it from.
 
 

Answers (15)