c# - How to debug "Cannot close an uninitialised Msg" FaultException? -
my app crashing because of "cannot close uninitialised msg" unhandled exception. due access socket multiple threads.
and have problem debugging issue because when review code access socket done in poller thread -- either in receiveready event handler directly (which run on poller thread definition understand it) or in manually created task (new task(...)) , started on poller thread (task.start(poller)). don't see place happen.
second problem is unhandled exception -- wrap sending/receiving in try-catch, yet exception happen somewhere outside.
i looking ways how debug , pinpoint place in code misbehaves.
code examples -- wrote use 2 "patterns":
using poller thread directly (thanks events fired on poller's thread):
private async void onmessagereceiveready(object sender, netmqsocketeventargs args) { netmqsocket socket = args.socket; netmqmessage mq_msg = socket.receivemultipartmessage(); ... switching poller's thread arbitrary thread:
task sending = new task(() => { foreach (netmqframe address in mq_envelope) socket.sendmoreframe(address.converttostring()); socket.sendframe(response_data); }); sending.start(this.sharedpoller); await sending.configureawait(false);
unfortunately didn't find other method trial&error , more logging.
and problem disposing sockets -- have running poller (shared) , tried remove , dispose socket, found out 2 methods asynchronous.
as solution group remove , dispose in separate task , schedule run in poller. having task in hand can call wait on , way achieve blocking, synchronous behaviour in dispose.
Comments
Post a Comment