question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked lextm answered

How to solve Permission Denied issue - Socket Exception in C#.Net core 3.1

Hi Team,

I have an C#.Net core 3.1 console application which is running on RedHat Linux.
The application is developed with SNMP Protocol Communication.
There is no issue, When i run my application at root user in Linux.
But when i run my application at normal user, the application is giving error.

Error:
Permission Denied (Socket Exception)

Please help me on this issue?

Regards,
Prabs

dotnet-csharpdotnet-runtimedotnet-cli
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

you need to learn linux. you need to configure the snmpd.config file (the same for any socket utility). the console app needs write access to the socket folder. while the version of linux you are using may vary.

see: (man snmpd.conf)

http://www.net-snmp.org/docs/man/snmpd.conf.html

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

lextm avatar image
0 Votes"
lextm answered

That's perfectly normal and expected, because to run a socket application on Linux and monitor incoming packets at reserved ports (161 and/or 162 for SNMP) require special permissions.

Running as root is the simplest way to acquire the permissions, but you can also configure it in other ways, https://unix.stackexchange.com/questions/10735/allowing-a-user-to-let-listen-to-a-port-below-1024

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.