title: GZipStream 4G limit - total or currently streaming?
body: <p>Have aa <code>GzipStream</code> feeding an <code>SSLStream</code>.</p>
  
  <p>First time today noticed
  "The gzip stream can't contain more than 4GB data."</p>
  
  <pre><code>at System.IO.Compression.FastEncoder.GetCompressedOutput(Byte[] outputBuffer)
  at System.IO.Compression.DeflateStream.InternalWrite(Byte[] array, Int32 offset, Int32 count, Boolean isAsync)
  at System.IO.Compression.DeflateStream.Write(Byte[] array, Int32 offset, Int32 count)
  at System.IO.Compression.GZipStream.Write(Byte[] array, Int32 offset, Int32 count)
  at ...
  </code></pre>
  
  <p>The Writer to the network is feeding in data faster than the Reader is getting the data. As such the cause of the error is unclear to me.</p>
  
  <p><strong>Is this is a limitation on the total bytes written through the stream or is this is an issue with backlog getting the data out of the <code>GZipStram</code> and into the <code>SSLStream</code>?</strong></p>
  
  <p>The Reader is able to unzip and use the data before the stream ends, so I never thought that there might be such a limit on total bytes written.</p>
  
  <p>There doesn't seem to be a way to check the length.</p>
  
  <p><strong>Could anybody share examples on how they handled this?</strong></p>
  
  <p>Code outline:</p>
  
  <pre><code>TcpClient network = = new TcpClient();
  network.Connect(m_config.Address.Host, m_config.Address.Port);
  SslStream sslStream = new SslStream(network.GetStream(), true .. ssl bits
  Stream outStream = new GZipStream(sslStream, CompressionMode.Compress, true);
  
  try {
      String nextMessage;
      while (messages.Dequeue(out nextMessage))
      {
          byte[] buffer = Encoding.UTF8.GetBytes(nextMessage + "\n");
  
          outStream.Write(buffer, 0, buffer.Length);
      }
  } catch()
  </code></pre>