Access denied for creating Alchemy WebSocket on Linux / Mono

My question is almost identical to mono / linux socket denied? but it seems that this question did not answer properly, so I am still stuck.

I have a server written using Alchemy WebSockets. I had it working fine on Windows, but after porting it to Linux, I can't get it to work. I get the following error every time I start the socket server:

System.Net.Sockets.SocketException: Access denied at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00051] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/Socket.cs:1104 at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00022] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/TcpListener.cs:268 at System.Net.Sockets.TcpListener.Start () [0x00000] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/TcpListener.cs:243 at Alchemy.TcpServer.Listen (System.Object state) [0x00000] in <filename unknown>:0 

I am trying to bind to a port above 1024 (in this case 12345), so this is not a problem. I do not start AppArmor or SELinux or something like that. The port is not used on my system. My user is a member of the network group, if that matters. My program will communicate with the socket if I run it using sudo, but this is not an ideal case.

Here is the code I use to create a socket and start listening:

  static public void Start(int port, string host) { _server = new WebSocketServer(port, IPAddress.Parse(host)); _server.OnConnect = OnConnected; _server.OnDisconnect = OnDisconnect; _server.Start(); } 

โ€œ12345โ€ is transmitted as โ€œportโ€ and โ€œ192.168.0.11โ€ (my local IP) is transmitted as โ€œhostโ€. I also tried IPAddress.Any to no avail.

+4
source share
2 answers

Alchemy issues a Flash policy file at 843 - try disabling flashsocketpolicy when creating an instance of your server.

+6
source

This is strictly an access issue.

My program will communicate with the socket if I run it using sudo, but this is not an ideal case.

This question has already been asked in a previous post on Stackoverflow. Is Mono / Linux Disabled?

I would try adding a โ€œuserโ€ to the sudo group, which will fix it as a quick fix. if it uses ICMP or Raw Sockets, it must run with root FYI privileges. Double check that Alchemy is not using this if you are a little unlucky to run it with superuser privileges.

I tried to post it as a comment, but it did not allow me, this is not a bona fide answer.

FYI to everyone you vote for.

+1
source

Source: https://habr.com/ru/post/1433688/


All Articles