Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetMQ.NetMQException: Exception of type 'NetMQ.NetMQException' was thrown at NetMQ.Core.Ctx.CreateSocket(ZmqSocketType type) #1081

Open
jatinrdave opened this issue Nov 8, 2023 · 0 comments

Comments

@jatinrdave
Copy link

jatinrdave commented Nov 8, 2023

Environment

NetMQ Version:    4.0.1.8
Operating System: Windows 10
.NET Version:     4.8.1

Expected behaviour

Actual behaviour

Throwing error:
"NetMQ.NetMQException: Exception of type 'NetMQ.NetMQException' was thrown.\r\n at NetMQ.Core.Ctx.CreateSocket(ZmqSocketType type)\r\n at NetMQ.NetMQSocket..ctor(ZmqSocketType socketType, String connectionString, DefaultAction defaultAction)\r\n at NetMQ.Sockets.PairSocket.CreateSocketPair(PairSocket& socket1, PairSocket& socket2)\r\n at NetMQ.Core.Utils.StopSignaler..ctor()\r\n at NetMQ.NetMQPoller..ctor()\r\n at NetMQ.NetMQRuntime..ctor()\r\n at WMService.API.Services.Services.WMDispatcherService.<>c__DisplayClass4_0.b__0()\r\n at System.Threading.Tasks.Task.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at WMService.API.Services.Services.WMDispatcherService.d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at WMService.API.Services.Services.WindowmakerInterfaceService.d__5.MoveNext()"

Steps to reproduce the behaviour

  • SendReceiveMessage always called when new API request comes.
  • Error occurs after much successful responses.

public async Task SendReceiveMessage(string messageString)
{
ResponseMessage responseMessage = new ResponseMessage() { message = string.Empty };

        //await Task.Delay(1);
        await Task.Factory.StartNew(() => {
            var netMQRuntime = new NetMQRuntime();
            netMQRuntime.Run(RunClient(messageString, responseMessage)); netMQRuntime.Dispose();
        });
        return responseMessage.message;

    }
    async Task RunClient(string messageString, ResponseMessage responseMessage)
    {

        using (var client = new DealerSocket())
        {

            bool more = false;
            try
            {
                string address = "tcp://127.0.0.1";
                string bindingAddress = $"{address}:{tcpPort}";
                client.Connect(bindingAddress);
                client.SendFrame(messageString);
                (responseMessage.message, more) = await client.ReceiveFrameStringAsync();
            }
            catch (Exception ex)
            {
                responseMessage.message = ex.ToString();
            }
            finally
            {
            }
        }
    }
@jatinrdave jatinrdave changed the title NetMQ.NetMQException: Exception of type 'NetMQ.NetMQException' was thrown NetMQ.NetMQException: Exception of type 'NetMQ.NetMQException' was thrown at NetMQ.Core.Ctx.CreateSocket(ZmqSocketType type) Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant