DotNetty icon indicating copy to clipboard operation
DotNetty copied to clipboard

How to solve the program freezing when calling bootstrap.BindAsync(localAddress).Result in Unity?

Open Siwen opened this issue 1 year ago • 2 comments

How to solve the program freezing when calling bootstrap.BindAsync(localAddress).Result in Unity?

Code:

     private void init () {
        _executorPool = executorPool;
        _executorPool.CreateMessageExecutor();
        _eventLoopGroup = eventLoopGroup;
        _scheduleThread = new EventLoopScheduleThread();
        bootstrap = new Bootstrap();
        bootstrap.Group(_eventLoopGroup);
        bootstrap.ChannelFactory(() => new SocketDatagramChannel(AddressFamily.InterNetwork));
        bootstrap.Handler(new ActionChannelInitializer<SocketDatagramChannel>(channel =>
        {
            var pipeline = channel.Pipeline;
            pipeline.AddLast(new ClientChannelHandler(_channelManager,channelConfig));
        }));
     }

    private static IChannel bindLocal(Bootstrap bootstrap,EndPoint localAddress = null)
    {
        if (localAddress == null)
        {
            localAddress = new IPEndPoint(IPAddress.Any, 0);
        }

        // ------> program freezing <------
        return bootstrap.BindAsync(localAddress).Result;
    }

Siwen avatar Aug 04 '23 04:08 Siwen

Same for me.

rekcah1986 avatar Sep 06 '23 03:09 rekcah1986