Hi @Pieter Souvereyns ,
The VB. NET code converted from C# is :
Async Function Main(ByVal args As String()) As Task
Dim client As HttpClient = New HttpClient()
client.Timeout = TimeSpan.FromSeconds(5)
Dim url As String = $"http://localhost:8080/rest/events"
Dim isDelay = False
While True
Try
Console.WriteLine("Establishing connection")
Using streamReader = New StreamReader(Await client.GetStreamAsync(url))
While Not streamReader.EndOfStream
Dim message = Await streamReader.ReadLineAsync()
Console.WriteLine($"Received message: {message}")
End While
End Using
isDelay = False
Catch ex As Exception
Console.WriteLine($"Error: {ex.Message}")
Console.WriteLine("Retrying in 5 seconds")
isDelay = True
End Try
If isDelay Then
Await Task.Delay(TimeSpan.FromSeconds(5))
End If
End While
End Function
Give it a try and if you get any exceptions, please provide a detailed description of the exception.
Hope it could be helpful.
Best Regards,
Jack