The script task is set to .NET 3.5. AssemblyInfo.cs contains 2.1.4.31
This might be more useful:
[] Information: zSystem.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)
at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)
at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)
at System.Net.ConnectStream.EnableWriteBuffering()
at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)
at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)
The server has 16Gb Ram, 8Gb free. I will try on a different machine on monday.
I'm working around this for now by streaming if it's <= 512Mb, and chunking it myself if > 512Mb calling CreateObject and UpdateObject to append each additional chunk. Which kind of missed the point of streaming the larger files, but is functional as most files are less than that.
Unfortunatley .NET 3.5 does not have the filestream.copyto so either way it end up in a byte and using memory.
I now have checksumming working, and have worked around the file size issue in a similar way to that suggested. I skipped the copystream method as it's just using byte[] anyway, so use the createobject directly in that case to save copying back to a stream. This seems to be working fine so far.
The complus error was a red herring, the error I still get when attempting a large file without the workaround is:
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> EsuApiLib.EsuException: Error executing request: The underlying connection was closed: Unable to connect to the remote server. ---> System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)
at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)
at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)
at System.Net.ConnectStream.EnableWriteBuffering()
at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)
at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at EsuApiLib.Rest.EsuRestApi.writeRequestBodyFromStream(HttpWebRequest con, Stream data, Int64 streamLength)
We still have issues when attempting to submit a 2.7Gb file via CreateFromStream, but the workaround of chunking @ 512Mb is so far OK. Mostly this won't be used, it's more for test coverage.
But would be good to get it working without still!
JasonCwik
281 Posts
0
August 20th, 2015 11:00
What version of the C# binding and the .NET SDK are in use? Is there a stack trace available anywhere?
We've never seen any COM errors before. Perhaps this is the error if there is an unhandled Exception in the script?
parody1
5 Posts
0
August 21st, 2015 03:00
Hi Jason
The script task is set to .NET 3.5. AssemblyInfo.cs contains 2.1.4.31
This might be more useful:
[] Information: zSystem.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)
at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)
at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)
at System.Net.ConnectStream.EnableWriteBuffering()
at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)
at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)
The server has 16Gb Ram, 8Gb free. I will try on a different machine on monday.
parody1
5 Posts
0
August 21st, 2015 07:00
I'm working around this for now by streaming if it's <= 512Mb, and chunking it myself if > 512Mb calling CreateObject and UpdateObject to append each additional chunk. Which kind of missed the point of streaming the larger files, but is functional as most files are less than that.
Unfortunatley .NET 3.5 does not have the filestream.copyto so either way it end up in a byte and using memory.
JasonCwik
281 Posts
0
August 21st, 2015 12:00
Can you post your whole code? This is very strange behavior. You should be able to use a smaller buffer and pass data to the stream:
public static void CopyStream(Stream input, Stream output){
byte[] buffer = new byte[32768];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write (buffer, 0, read);
}
}
parody1
5 Posts
0
September 8th, 2015 02:00
Hi
Apologies for the delay, I was on leave.
I now have checksumming working, and have worked around the file size issue in a similar way to that suggested. I skipped the copystream method as it's just using byte[] anyway, so use the createobject directly in that case to save copying back to a stream. This seems to be working fine so far.
The complus error was a red herring, the error I still get when attempting a large file without the workaround is:
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> EsuApiLib.EsuException: Error executing request: The underlying connection was closed: Unable to connect to the remote server. ---> System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Net.ScatterGatherBuffers.MemoryChunk..ctor(Int32 bufferSize)
at System.Net.ScatterGatherBuffers.AllocateMemoryChunk(Int32 newSize)
at System.Net.ScatterGatherBuffers..ctor(Int64 totalSize)
at System.Net.ConnectStream.EnableWriteBuffering()
at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream submitStream)
at System.Net.Connection.CompleteConnection(Boolean async, HttpWebRequest request)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at EsuApiLib.Rest.EsuRestApi.writeRequestBodyFromStream(HttpWebRequest con, Stream data, Int64 streamLength)
at EsuApiLib.Rest.EsuRestApi.CreateObjectFromStream(Acl acl, MetadataList metadata, Stream data, Int64 streamLength, String mimeType, Checksum checksum)
--- End of inner exception stack trace ---
at ST_3fd03fc03c144d9eb015ae46a529d171.csproj.ScriptMain.Main()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
JasonCwik
281 Posts
0
September 8th, 2015 07:00
So, is everything working correctly now or do you still have issues?
parody1
5 Posts
0
September 8th, 2015 08:00
Hi Jason
We still have issues when attempting to submit a 2.7Gb file via CreateFromStream, but the workaround of chunking @ 512Mb is so far OK. Mostly this won't be used, it's more for test coverage.
But would be good to get it working without still!