C# - blocking GetRequestStream()

Hi, I’m trying to get some data from Aerospike into SOLR, but I’m having a little problem with the web requests to solr. I’m using c#-s HttpWebRequest for the web requests on multiple threads. After a few batches the process gets blocked. I found out that the code stops at the data = request.GetRequestStream(); line, no exceptions, no messages, no timeouts it just waits and does nothing. Here is a part of my code:

public static ConcurrentBag docs = new ConcurrentBag(); public static int count { get; set; }

<< data extraction into the “docs” container >>

if (count == 50) { string dataStr = “{”; string temp; lock (docs) { while (!docs.IsEmpty) { docs.TryTake(out temp); dataStr += temp; } } dataStr = dataStr.ToString().Remove(dataStr.ToString().Length - 1) + “}”; count = 0; string SOLRInsert = “http:// 192.168.23.28:8985/solr/test/update”;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(SOLRInsert);
request.ContentType = "application/json";
request.Method = "POST";
byte[] dataBytes = Encoding.ASCII.GetBytes(dataStr);
request.ContentLength = dataBytes.Length;
request.Proxy = null;

Stream data = null;

try
{
    data = request.GetRequestStream();
    sw.Start();
    data.Write(dataBytes, 0, dataBytes.Length);
    sw.Stop();
    //data.Close();
    data.Dispose();
}
catch (Exception ex)
{
    Console.Write(key.userKey.ToString() + "->" + ex.ToString() + "\r\n");
    File.AppendAllText(@"import.log", key.userKey.ToString() + "->" + ex.ToString() + Environment.NewLine);
}
finally
{
    if (data != null)
    {
        //data.Close();
        data.Dispose();
    }
}

}

Any help would be appreciated! Thank you