Azure / Azure/DotNetty

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

Open
#610 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.3k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

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(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;
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.