zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

socket.SendFrame(bytes) throws NetMQ.FaultException: Cannot close an uninitialised Msg #952

Closed bradmarder closed 3 years ago

bradmarder commented 3 years ago

Environment

NetMQ Version:    4.0.1.6 
Operating System:  ubuntu 18.04
.NET Version: 5

Using a publisher socket in a tight loop, sending random packets will occasionally trigger this exception. It's either using the SendFrames(byte[], int) overload or just the (byte[]), I'm not sure which causes it.

NetMQ.FaultException: Cannot close an uninitialised Msg.
   at NetMQ.Msg.Close()
   at NetMQ.Core.Transports.EncoderBase.Encode(ByteArraySegment& data, Int32 size)
   at NetMQ.Core.Transports.StreamEngine.BeginSending()
   at NetMQ.Core.Transports.StreamEngine.FeedAction(Action action, SocketError socketError, Int32 bytesTransferred)
   at NetMQ.Core.ZObject.ProcessCommand(Command cmd)
   at NetMQ.Core.IOThread.Ready()
   at NetMQ.Core.Utils.Proactor.Loop()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
bradmarder commented 3 years ago

Closing this issue because I realized netmqsockets are not threadsafe.