Streaming API - Not returning any updates

I have the below code being run, it authenticates and holds the connection open. It just doesn’t show any results, I am clearly missing something obvious. I don’t have a timepoint, so only know it can’t be right as its been running for hours without anything. An echo service to prove the connection would be great, this is making testing painful.

        var url = "";

        using (var client = new HttpClient())
            client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);

            var authenticationString = "*********";

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Functions.Base64Encode(authenticationString));
            Console.WriteLine("Key is: " + Functions.Base64Encode(authenticationString));

            var request = new HttpRequestMessage(HttpMethod.Get, url);
            using (var response = new StreamReader(await client.GetStreamAsync(url)))
                while (!response.EndOfStream)
                    var message = await response.ReadLineAsync();
                    Console.WriteLine("message: " + message);

Are you able to try a simple curl command eg:-
curl -vv -k -u :

That works Mark, so proves the connection and results, it is sounding like my way of processing the response is invalid so welcome any .Net views on this.

This may help, managed to get it working using the following code project, had to change a few things but it’s a good start. Hopefully this helps.

Thanks, got it working. My error in approach was to try to make the response fit into a HttpResponseMessage which is fairly typical, but not when you are dealing with this type of continuous stream it would seem.

1 Like