Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting System.ArgumentException: Destination array was not long enough. when re-opening a stream #117

Open
bohao-cao opened this issue Dec 12, 2017 · 4 comments

Comments

@bohao-cao
Copy link

Environment: Dot net core application running in a docker container.

Issue

  1. Web socket connection is broken
  2. Try to reset the socket by following When trying to re-open a closed websocket I am getting SocketException "Operation not supported" #100
  3. Get SocketException from webSocket's error handler. Error:System.Net.Sockets.SocketException (0x80004005): Transport endpoint is not connected
  4. Get close event from webSocket's close handler.
  5. Get unhandled Exception. Stack trace:

Unhandled Exception: System.ArgumentException: Destination array was not long enough. Check the destination index, length, and the array's lower bounds.
Parameter name: destinationArray
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at WebSocket4Net.Common.ArraySegmentList1.CopyTo(T[] to, Int32 srcIndex, Int32 toIndex, Int32 length) at WebSocket4Net.WebSocketCommandInfo..ctor(IList1 frames)
at WebSocket4Net.Protocol.DraftHybi10DataReader.GetCommandInfo(Byte[] readBuffer, Int32 offset, Int32 length, Int32& left)
at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length)
at SuperSocket.ClientEngine.AsyncTcpSession.ProcessReceive(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.ExecutionCallback(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncSuccess(Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionCallback(Int32 bytesTransferred, SocketFlags flags, SocketError socketError)
at System.Net.Sockets.SocketAsyncEventArgs.TransferCompletionCallbackCore(Int32 bytesTransferred, Byte[] socketAddress, Int32 socketAddressSize, SocketFlags receivedFlags, SocketError socketError)
at System.Net.Sockets.SocketAsyncContext.ReceiveOperation.InvokeCallback()
at System.Net.Sockets.SocketAsyncContext.AsyncOperation.<>c.b__14_0(Object o)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()

@bohao-cao bohao-cao changed the title Getting System.ArgumentException: Destination array was not long enough. when opening a stream Getting System.ArgumentException: Destination array was not long enough. when re-opening a stream Dec 12, 2017
@kerryjiang
Copy link
Owner

Can it be reproduced outside docker?

@bohao-cao
Copy link
Author

bohao-cao commented Dec 12, 2017

This issue happened only once under stress test.

@bohao-cao
Copy link
Author

bohao-cao commented Dec 12, 2017

ArraySegmentList.CopyTo(T[] to, int srcIndex, int toIndex, int length) ln 492 throws.
A naive example will throw the same argument exception.
int[] a = { 1, 2, 3};
int[] b = { 9,10,11};
Array.Copy(a,0,b,1,3);

@kerryjiang
Copy link
Owner

Ok, I'll check this issue soon. That would be great, if you provide some test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants