IzzyTwinkly
asked on
Processing Continuous JSON stream using C#
Hi guys,
I am trying to process Continuous(endless) JSON stream using C#.
I wrote the following code for this, but it doesn't display anything but </html> on the screen.
What should I do to see the continuously coming JSON stream?
Thanks!
I am trying to process Continuous(endless) JSON stream using C#.
I wrote the following code for this, but it doesn't display anything but </html> on the screen.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args){
var url = "http://localhost/myWebService/endlessJsonStream";
Task<string> t1 = OnContinuousJason(url);
Console.Write(t1.Result);
Console.Read();
}
private static async Task<string> OnContinuousJason(string url)
{
var client = new HttpClient();
client.Timeout = TimeSpan.FromMilliseconds( Timeout.Infinite);
var request = new HttpRequestMessage(HttpMethod.Get, url);
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
var body = await response.Content.ReadAsStreamAsync();
var reader = new StreamReader(body);
var result = "";
while (!reader.EndOfStream)
{
result = reader.ReadLine();
}
return result;
}
}
}
What should I do to see the continuously coming JSON stream?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But this is important. You need to ask the developer or vendor.
ASKER
Hi ste5an,
it's rest and wcf. I got confirmed.
it's rest and wcf. I got confirmed.
ASKER
I don't know what is going on with the production code under the hood.
So with that given URL, I can't display the continuous Json stream?
As I know, wcf and rest are used.
Thanks.