Skip to content

NETMQ fails on Linux: Windows-specific control codes and is not supported on this platform. #958

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

Open
maxima120 opened this issue Dec 30, 2020 · 10 comments

Comments

@maxima120
Copy link

maxima120 commented Dec 30, 2020

Environment

NetMQ Version:   4.0.1.6
Operating System: CentOS8
.NET Version:  5.0.1

Expected behaviour

should work as promised on .NET Core platform

Actual behaviour

Fails

Steps to reproduce the behaviour

try to connect to a NETMQ server from ASP.NET Core app

Unhandled exception. System.PlatformNotSupportedException: Socket.IOControl handles Windows-specific control codes and is not supported on this platform.
   at System.Net.Sockets.SocketPal.WindowsIoctl(SafeSocketHandle handle, Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue, Int32& optionLength)
   at System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
   at System.Net.Sockets.Socket.IOControl(IOControlCode ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
   at AsyncIO.DotNet.NativeSocket.IOControl(IOControlCode ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
   at NetMQ.Core.Transports.Tcp.TcpConnector.OutCompleted(SocketError socketError, Int32 bytesTransferred)
   at NetMQ.Core.IOObject.OutCompleted(SocketError socketError, Int32 bytesTransferred)
   at NetMQ.Core.Utils.Proactor.Loop()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
@daconglee
Copy link

up

@wjrogers
Copy link

wjrogers commented Nov 1, 2021

FYI, support for TCP keep-alive was added to SetSocketOption() in .NET Core 3.0. Unfortunately, the new option names were never added to .NET Standard, so supporting TCP keep-alive on Linux would require adding a netcoreapp3.1 (or newer) target to NetMQ. Then, code similar to this could be introduced to TcpConnector and TcpListener:

#if NETCOREAPP3_1
// for .NET (Core) with the new socket options, use them (N.B. SetSocketOption units are seconds, not milliseconds)
if (m_options.TcpKeepaliveIdle != -1)
    m_s.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, m_options.TcpKeepaliveIdle / 1000);
if (m_options.TcpKeepaliveIntvl != -1)
    m_s.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, m_options.TcpKeepaliveIntvl / 1000);
#else
// ... retain existing code path for Windows / .NET Framework
#endif

@dnovhorodov
Copy link

Any news on the issue? When a fix could be expected?
Running 4.0.1.6 version of NetMQ with netcoreapp3.1 is failing

@RWander
Copy link

RWander commented Jun 9, 2022

up!

@RWander
Copy link

RWander commented Jun 9, 2022

Running with net6.0 is failing as well!

@danielsilva-iq
Copy link

up!

@SpiritDogstar
Copy link

bump

@chrbauer
Copy link

I added wjrogers suggestion to a branch. For simplicity only .net8 is now supported:

https://github.com/chrbauer/netmq/tree/net8/tcp-keepalive-linux

It compiles, all tests are green. All nugets are up to date.

@chrbauer
Copy link

chrbauer commented Apr 4, 2025

What do we need to do for an acceptable pull request?

  1. There is a dedicided branch only for .net8 version. (This is currently the solution in the patch from the previous comment).
  2. We replace netstandard2.1 by netcoreapp3.1 and set TCP KeepAlive with #if NETCOREAPP_3_1
  3. Like 2, but we keep the netstandard2.1 target

@chrbauer
Copy link

Hm. netcoreapp3.1 is not working, but net8.0.
==> #1120

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

8 participants