• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    BACnetTimeoutException: No response from instanceId and Unable to find router to network Unable to find router to network

    BACnet4J general discussion
    2
    4
    2.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anandbiradar
      last edited by

      While discovering the BACnet device in my application I get the following errors when running the code below.

      • com.serotonin.bacnet4j.exception.BACnetException: Unable to find router to network 40208
      at com.serotonin.bacnet4j.transport.DefaultTransport$Outgoing.send(DefaultTransport.java:304)
      at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:439)
      at java.lang.Thread.run(Thread.java:748)

      • com.serotonin.bacnet4j.exception.BACnetTimeoutException: No response from instanceId 888541
      at com.serotonin.bacnet4j.util.RemoteDeviceFinder$DeviceFutureImpl.get(RemoteDeviceFinder.java:176)
      at com.serotonin.bacnet4j.LocalDevice.getRemoteDeviceBlocking(LocalDevice.java:800)
      at com.serotonin.bacnet4j.LocalDevice.getRemoteDeviceBlocking(LocalDevice.java:744)
      at com.serotonin.bacnet4j.service.unconfirmed.IHaveRequest.lambda$handle$0(IHaveRequest.java:79)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

      The code I wrote for this looks somewhat like program in attached.
      Could you please let me know what I'm doing wrong and how to avoid these exceptions?

      //
      public static void main(String[] args) throws ServiceException {
      
              Integer deviceId = 1234;
              String port = 0xBAC0, localBindAddress = "192.168.0.145";
      
              IpNetworkBuilder builder = new IpNetworkBuilder();
              builder.port(Integer.decode(port));
              builder.localBindAddress(localBindAddress);
      
              IpNetwork network = builder.build();
              LocalDevice localDevice = new LocalDevice(deviceId, new DefaultTransport(network));
              try {
                  localDevice.initialize();
              } catch (Exception e) {
                  throw new ServiceException("Unable to initialize localDevice", e);
              }
      
              localDevice.getEventHandler().addListener(new DeviceEventAdapter() {
                  @Override
                  public void iAmReceived(RemoteDevice remoteDevice) {
                      logger.debug("iAm Received from device: {}, NetworkNumber: {}",
                              remoteDevice.getInstanceNumber(),
                              remoteDevice.getAddress().getNetworkNumber()
                      );
      
                      Runnable task = () -> {
                          try {
                              DiscoveryUtils.getExtendedDeviceInformation(localDevice, remoteDevice);
                              SequenceOf<ObjectIdentifier> oids = RequestUtils.getObjectList(localDevice, remoteDevice);
      
                              for (ObjectIdentifier oid : oids) {
                                  String name = ((CharacterString) RequestUtils.getProperty(localDevice, remoteDevice, oid,
                                          PropertyIdentifier.objectName)).getValue();
                                  logger.info("Found object oid={}, name={} in device {}",
                                          oid,
                                          name,
                                          remoteDevice.getInstanceNumber()
                                  );
                              }
      
                              while(true) {
                                  for (ObjectIdentifier oid : oids) {
                                      Encodable value = RequestUtils.getProperty(
                                              localDevice,
                                              remoteDevice,
                                              oid,
                                              PropertyIdentifier.presentValue
                                      );
                                      logger.info("{}={}", oid, value);
                                  }
                                  try {
                                      Thread.sleep(5_000L);
                                  } catch (InterruptedException e) {
                                  }
                              }
                          } catch (BACnetException e) {
                              logger.error("Error getting values from remoteDevice", e);
                          }
                      };
                      new Thread(task).start();
                  }
              });
      
              InetSocketAddress addr = InetAddrCache.get("192.168.1.99", IpNetwork.DEFAULT_PORT);
              int port = IpNetwork.DEFAULT_PORT;
              byte[] ipAddress1 = addr.getAddress().getAddress();
              
              byte[] ipMacAddress = new byte[ipAddress1.length + 2];
              System.arraycopy(ipAddress1, 0, ipMacAddress, 0, ipAddress1.length);
              ipMacAddress[ipAddress1.length] = (byte) (port >> 8);
              ipMacAddress[ipAddress1.length + 1] = (byte) port;
              OctetString macAddress123 = new OctetString(ipMacAddress);
              
              Address addr1 = new Address(macAddress123);
              localDevice.send(addr1, new WhoIsRequest());
          }
      
      
      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi anandbiradar,

        Have you attempted setting the local network number in the IpNetworkBuilder?

        A 1 Reply Last reply Reply Quote 0
        • A
          anandbiradar @phildunlap
          last edited by

          @phildunlap How do i set local network number in IpNetworkBuilder?

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            The "withLocalNetworkNumber" function, https://github.com/infiniteautomation/BACnet4J/blob/master/src/main/java/com/serotonin/bacnet4j/npdu/ip/IpNetworkBuilder.java

            1 Reply Last reply Reply Quote 0
            • First post
              Last post