Share via

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

Developer technologies | .NET | .NET Runtime
Developer technologies | .NET | .NET CLI
Developer technologies | C#
Developer technologies | 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.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Lex Li 6,042 Reputation points
    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

  2. Bruce (SqlWork.com) 83,666 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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.