Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Troubleshoot Exception Errors in a NETCONF Java Application

The following sections outline exception errors that you might encounter when executing a NETCONF Java toolkit program. These sections also present potential causes and solutions for each error.

Troubleshooting Connection Errors: Socket Timed Out

Problem

Description

A NETCONF exception occurs, and you see the following error message:

Cause

Potential causes for the socket timed out error include:

  • The device or interface to which you are connecting is down or unavailable.

  • The IP address or hostname in the arguments for the Device object is incorrect.

  • The connection timeout value was exceeded before the connection was established.

Solution

Ensure that the device is up and running. Also verify that the IP address or hostname is correct in the arguments of the Device constructor in your program code.

The default timeout value for connecting to a device is 5000 milliseconds. To set the timeout value to a larger interval to ensure that the program has sufficient time to establish the connection, call the setTimeOut() method on the device object. The following code sets the timeout interval to 10 seconds:

Troubleshooting Connection Errors: No Connection

Problem

Description

An IllegalStateException exception occurs, and you see the following error message:

Cause

An SSHv2 connection or NETCONF session was not established with the remote device.

Solution

Call the connect() method on the device object to establish an SSHv2 connection and a default NETCONF session with the device on which the NETCONF server runs. Once the connection and session are established, RPC execution should be successful.

Troubleshooting Authentication Errors

Problem

Description

A NETCONF exception occurs, and you see the following error message:

Cause

An error message for failed authentication could have several possible causes, including the following:

  • The host or authentication details passed as arguments to the Device constructor are incorrectly entered in the program code.

  • The arguments for the Device object are correct, but there is no corresponding user account created on the device to which you are connecting.

Solution

If there is no user account on the device to which you are connecting, create the account with the appropriate authentication. For more information about configuring user accounts on a device running Junos OS, see the Junos OS User Access and Authentication User Guide for Routing Devices .

If the user account exists on the remote device, but the arguments for the Device constructor are entered incorrectly in the program code, correct the arguments and recompile the program.

Troubleshooting NETCONF Session Errors

Problem

Description

A NETCONF exception occurs, and you see the following error message:

Cause

NETCONF over SSH might not be enabled on the device where the NETCONF server resides, or it might be enabled on a different port.

Solution

Ensure that you have enabled NETCONF over SSH on the device where the NETCONF server resides. If your NETCONF Java toolkit program does not specify a specific port number in the Device argurments, the NETCONF session is established on the default NETCONF-over-SSH port, 830. To verify whether NETCONF over SSH is enabled on the default port for a device running Junos OS, enter the following operational mode command on the remote device:

If the netconf configuration hierarchy is absent, issue the following statements in configuration mode to enable NETCONF over SSH on the default port:

If the netconf configuration hierarchy specifies a port other than the default port, you should include the new port number in the Device object constructor arguments. For example, the following device is configured for NETCONF over SSH on port 12345:

To correct the connection issue, include the new port number in the Device arguments.