I am calling webdis with .NET C# using the SUBSCRIBE command. I have run into situations where reading the stream gives me a timeout. Is there any way to maintain a connection? Is there a better approach than the code I have included below?
Here is the code I am using?
static async Task ReadDataFeed()
{
var url = "http://mydomain.com:7379/SUBSCRIBE/myproduct:json:stream:5";
using (var client = new HttpClient())
{
client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
var msgBuilder = new StringBuilder();
var request = new HttpRequestMessage(HttpMethod.Get, url);
using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
{
using (var body = await response.Content.ReadAsStreamAsync())
using (var reader = new StreamReader(body))
{
while (!reader.EndOfStream)
{
// Read data from the stream
var buffer = new char[8192];
var bytesRead = await reader.ReadAsync(buffer, 0, buffer.Length);
//... process the buffer here
}
}
}
}
}
I am calling webdis with .NET C# using the SUBSCRIBE command. I have run into situations where reading the stream gives me a timeout. Is there any way to maintain a connection? Is there a better approach than the code I have included below?
Here is the code I am using?
Thanks!