Closed zxarcg closed 7 years ago
if you could put it out (let's say in a branch of your fork) I could check it out. It's hard to understand the problem without the context.
hi nayato,
please view https://github.com/zxarcg/DotNetty 。
hi nayato,
Through debug, i found reason. because in "bool RunAllTasks(PreciseTimeSpan timeout) in SingleThreadEventExecutor.cs" , task.Run() is synchronous, and my task action code is " while(true)..", so next tasks always can't run . so i only exit from task's while clause , EchoServerHandler ChannelRead method can be called.
is it a bug ?
i think maybe it's reason is netty 4.x thread model, all read/write is executed serial by netty nioeventloop, and my business task is wrapped by netty task, and is executed by serial, so my business task impact io read /write.
It certainly isn't DotNetty's bug. You are expected not to block the event loop and that's exactly what you do with while (true)
. You may still maintain the tight loop semantics if you'd like by scheduling the same method to event loop through IEventExecutor.Execute(..).
I only create a test class, code is as followed, then in EchoServerHandler class , add TestUserThread _thread = new TestUserThread(); then server always can't receive client message。Remove last line , i can receive message。but if i use "System.Threading.Thread thread = new System.Threading.Thread(SendMessage);..", i can receive message. Too strange, please help me.
public class TestUserThread { public TestUserThread() { Task.Factory.StartNew(SendMessage, TaskCreationOptions.LongRunning);
}