System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) on Mono
Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!
-
A brief description With Mono 4.8, it's not a mono problem, I checked on other Ubuntu 14.04 16.04 machines. when starts XSocketsServer.Start() it throws Got a bad hardware address length for an AF_PACKET 16 8 // this may or may not matter Got a bad hardware address length for an AF_PACKET 16 8 2017-01-28 07:23:09 [Error] Error in XSocketServer.Start() System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00023]
-
Expected results runs without problem, and it ran no problem on earlier builds (I don't remember build number)
-
Actual results (with terminal output if applicable) Got a bad hardware address length for an AF_PACKET 16 8 Got a bad hardware address length for an AF_PACKET 16 8 2017-01-28 07:23:09 [Error] Error in XSocketServer.Start() System.ArgumentException: Value does not fall within the expected range. at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00023] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket.set_DontFragment (System.Boolean value) [0x00009] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket.SocketDefaults () [0x00009] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x00095] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at System.Net.Sockets.TcpListener..ctor (System.Net.IPEndPoint localEP) [0x0002d] in <1ac50aac877347fd9fa1bbebe4ae149e>:0 at XSockets.Server.XSocketServer+
d__16.MoveNext () [0x0012a] in <4883760312cf4ca3ab413ae42c1df4f3>:0 -
Your Windows build number tested on 10.0.15014, 10.0.15019
-
Steps / All commands required to reproduce the error from a brand new installation create a project, reference XSockets.Server 5.7.1 from nugget, and create a class inherits XSocketController, new the class, start the server.
-
Strace of the failing command N/A
-
Required packages and commands to install Mono 4.8, it's RC for now, install instruction for beta Mono packages: http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives-beta-channel
See our contributing instructions for assistance.
@imkow - Thanks for the bug report and the feedback. Can you share out an strace? That would be really useful in this case. To collect an strace:
strace -o <strace_file> -ff <failing command>
Trace file is generated with Mono 4.9 snapshot ci packages: http://www.mono-project.com/docs/getting-started/install/linux/ci-packages/
Guh. I've never understood why so many coders think it is a good idea to spin on gettimeofday(). Anyway, this seems to be the problem:
setsockopt(4, SOL_IP, IP_MTU_DISCOVER, [0], 4) = -1 EINVAL (Invalid argument)
Ignoring the gettimeofday() storm it fails with dotnet System.ArgumentException soon afterward.
#69 #717
I've created a new ticket on uservoice: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17872294-setsockopt-fd-ipproto-ip-ip-mtu-discover-fla
#69 #717
Thanks for reporting this. We support IP_MTU_DISCOVER for datagram inet sockets, but not for stream inet sockets. This is actually a Windows networking (WSK) limitation and we are working with the networking team for them to add support.
Full support from the networking team would be nice, but 90% of the value would be achieved by silently ignoring the option, rather than returning an error for it.
(I have a non-public project which runs on Mono on Linux, but not on Windows, because of this issue. I don't care whether there's MTU discovery, but this results in a crash-on-startup.)
@jimrandomh - Thanks for your comment. Full support for IP_MTU_DISCOVER has already been checked-in the dev branch, sometime back. It should soon be in the Insider builds.
This should be fixed in Insider build 16215
I got these using Ubuntu 16.04.3 LTS, Release 16.04 and mono 5.2.0.215: Is this related?
.NET Runtime Version: 4.0.30319.42000
Operating System Version: Unix 4.4.0.43
Working Directory: x
Language: fr-CA
Process Id : 30581
2017-08-25 08:41:09,592 [Main] INFO - Mono Version : 5.2.0.215 (tarball Mon Aug 14 15:46:23 UTC 2017)
System.ArgumentException: Value does not fall within the expected range.
at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int
32 optionValue) [0x00023] in
Same while running xsp
Completely fresh install of Bash on Windows with just mono and xsp installed
Running Bash on Windows with Ubuntu 14.04.5 LTS
Mono JIT compiler version 5.2.0.215
@FelixBrunet & @IliqNikushev - What is your Windows version (output of the ver command from CMD)?
Also, it's difficult to say which socket option it is tripping on without a trace. Can you collect a trace and share it out?
strace -o <trace_file> -ff <failing_cmd>
Microsoft Windows [Version 10.0.15063] fail socket mono.zip
@FelixBrunet - Thanks.
setsockopt(4, SOL_IP, IP_MTU_DISCOVER, [0], 4) = -1 EINVAL (Invalid argument)
As mentioned above, the issue is resolved in the Insider build 16215 (you are on 15063), which will also be available in Fall Creators Update.