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

Prabs 1 Reputation point
2021-07-19T10:10:26.723+00:00

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

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
323 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,286 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2021-07-19T15:54:47.87+00:00

    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

    0 comments No comments

  2. Lex Li (Microsoft) 4,742 Reputation points Microsoft Employee
    2021-07-20T01:08:45.523+00:00

    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

    0 comments No comments