Need help from you big time. I'm stuck up at an issue for over 2 days now and couldn't find a solution for this even in google!!
Anyway, I'll just post my problem below. Please help me at the earliest
I've been trying to develop an SNMP agent using an API called Friendly SNMP(it is a wrapper around Snmp4j) and things were great initially as everything was smooth. Now, when I'm trying to send traps/notifications to a remote machine which is in my system's network, i'm getting a pretty frustrating Bind Exception with a message "Cannot assign requested address". Here is the stacktrace.
2011-06-08 14:25:30,180 - org.friendlysnmp.FException - ERROR - Failure to init SNMP agent
 java.net.BindException: Cannot assign requested address
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
However, everything works well if I use localhost/127.0.0.1 as the IP address where the traps are sent. Creepy that!!
Attempts at Solving
1) I've done a netstat to see if the port is already bound and apparently the port is free. So, this is out of question.
2) I've pinged the remote host, done a telnet and everything is working.
3) There are a lot of discussions which have mentioned that we need to set some options in JVM to use IPv4 address by default. I've done this, but no luck
4) I've tested this on a Windows machine and no success.
So, please help me guys, i'm stuck up in my project. Let me know if I need to make some changes in the /etc/hosts file or something.
I'm attaching my properties file(where i specify the IP address) and the log file for reference.
PS : Oh, and please ignore the way I specify the IP and port in the properties file, that is how the API expects it.
PS2 : Unfortunately, I'm unable to attach any file. So, please find the log below.
Properties file is below # NOTE: Some of the values below are defined as SET nodes and
# might be overwritten by MIB manager and persist between sessions.
# See FConstant class for full list of valid entries in the properties.
# Address of THIS application to respond on SET and GET requests
# The address 161 might be already used by Windows SNMP service.
# Address to send notifications
# Disallow application boots count reset.
# The entry is optional. Default value is true.
# Local engine ID.
# The entry is optional. This value overrides default generated value.
# NOTE: This value for SNMPv3 must match target EngineID in MIB browser
# (if it is set not empty)
# Heartbeat interval (seconds).
# This is interval in seconds how often heartbeat notifications are sent.
# The entry is optional. Default value is 0 sec.
# This value is ignored if it is set explicitly from MIB browser.
# FriendlySNMP might receive multiple GET NEXT with subrequests
# for the same SNMP object in a short period of time. Each
# of these requests would fire update event. The application
# might want to coalesce duplicate update events into a single
# one. If identical update events are received in the
# following time frame only a single update event will be fired.
# Allowed values are 0 .. 10,000 ms.
# The entry is optional. Default value is 1000 ms.
# Root OID for views.
# These entries are optional. Default values are "1.3".
# Thread pool size.
# The entry is optional. Default value is 4.
# Filename to store serialized default persistence storage.
# The entry is optional. Default filename is generated from main app classname.
# Transport. Valid values are: UDP or TCP.
# The entry is optional. Default value is UDP.
# Transport domain. Valid values are: IPV4, IPV4Z, IPV6, IPV6Z.
# The entry is optional. Default value is IPV4
# Storage type.
# MIB StorageType TC: Describes the memory realization of a conceptual row.
# A row which is volatile(2) is lost upon reboot. A row which either
# nonVolatile(3), permanent(4) or readOnly(5), is backed up by stable storage.
# A row which is permanent(4) can be changed but not deleted. A row which is
# readOnly(5) cannot be changed nor deleted.
# If the value of an object with this syntax is either permanent(4) or
# readOnly(5), it cannot be written. Conversely, if the value is either
# other(1), volatile(2) or nonVolatile(3), it cannot be modified to be
# permanent(4) or readOnly(5).
# Upper or lower case is ignored.
# These entries are optional. All defaults are "readOnly"
# Notification timeout.
# The entry is optional. Default value is 1000 ms.
# Notification retry count.
# The entry is optional. Default value is 1 time.
# List of v1/v2 communities separated by spaces, e.g. "public snmp"
# List of v3 users separated by spaces, e.g. "john craig"
# Security section for v3.
# These values are not used until "snmp.v3.user=.." entry is specified.
# Authentication and privilege passwords (passphrases) should be encoded
# using the FriendlyPro tool with the specified or default key.
# Valid auth protocols: none, MD5, SHA
# Valid priv protocols: none, DES, AES128, AES192, AES256
# Default protocols are "none" or define empty value for "none".
# Decrypted passwords: "SHAAuthPassword" and "DESPrivPassword"
# Uncaught exceptions are handled by agent and their stack traces are not
# shown by JVM in a console. Set this value to "true" in development
# environment to see stack traces and to "false" in production to keep
# console clean.
# The entry is optional. Default value is "true".
# Persistency policy. The entry is optional.
# Valid values are "on_change" and "on_exit". Default value is "on_change"
I've never used the API you're using so they might confuse some things but it sound like you got the fundamentals of SNMP wrong. An SNMP agent is the client in the server - client network model which applies to SNMP so you don't need to bind anything. Binding to ports is strictly a server discipline and involves tying a piece of software to a port on the local computer, usually to a port number in the range 1-1023 which you should keep clear of unless you know what you are doing.
Philip Grove wrote:I've never used the API you're using so they might confuse some things but it sound like you got the fundamentals of SNMP wrong. An SNMP agent is the client in the server - client network model which applies to SNMP so you don't need to bind anything. Binding to ports is strictly a server discipline and involves tying a piece of software to a port on the local computer, usually to a port number in the range 1-1023 which you should keep clear of unless you know what you are doing.