kerryjiang / SuperSocket

SuperSocket is a light weight, cross platform and extensible socket server application framework.
Apache License 2.0
3.95k stars 1.15k forks source link

2.0 启用Udp后 断点调试就崩溃 #601

Closed 2576168920 closed 2 years ago

2576168920 commented 2 years ago

image

    static async Task Main(string[] args) 
    {
        var host = SuperSocketHostBuilder.Create<StringPackageInfo, CommandLinePipelineFilter>()
            .UseUdp()
            .UsePackageHandler(async (session, package) =>
            {  //Udp此处断点调试直接崩溃,Tcp没有该现象
                var result = 0;
                await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
            })
            .ConfigureSuperSocket(options =>
            {
                options.Name = "Echo Server";
                options.Listeners = new List<ListenOptions> {
                    new ListenOptions
                    {
                        Ip = "Any",
                        Port = 2012
                    }
                };
            })
            .Build();

        await host.RunAsync();
    }
chucklu commented 2 years ago

Can not reproduce this issue, please try again with the following code, and don't forget to take a screenshot

Func<IAppSession, StringPackageInfo, ValueTask> packageHandler = async (session, package) =>
{
    try
    {
        var result = 0;
        await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
};

var host = SuperSocketHostBuilder.Create<StringPackageInfo, CommandLinePipelineFilter>()
    .UseUdp()
    .UsePackageHandler(packageHandler)
    .ConfigureSuperSocket(options =>
    {
        options.Name = "Echo Server";
        options.Listeners = new List<ListenOptions> {
            new ListenOptions
            {
                Ip = "Any",
                Port = 2012
            }
        };
    })
    .Build();

await host.RunAsync();
2576168920 commented 2 years ago

image

chucklu commented 2 years ago

@2576168920 Please report this issue here, https://developercommunity.visualstudio.com/t/memory-could-not-be-read/720186 It's not the problem of SuperSocket, what's the visual studio version you are using?

I am using vs 2022 with verison 17.3 which works fine with above code. C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe

chucklu commented 2 years ago

I suggest you Google with "devenv.exe The memory could not be read" first. You will get something like this https://developercommunity.visualstudio.com/t/vs2019-crashes-at-breakpoint/714437

2576168920 commented 2 years ago

奇怪的问题,tcp就没问题udp才有这问题,谢谢