What is the configured maximum thread pool size for bacnet4j library to handle the requests and responses from BACnet devices?
Latest posts made by anandbiradar
-
Bacnet4j thread pool size
-
RE: BACnetTimeoutException: No response from instanceId and Unable to find router to network Unable to find router to network
@phildunlap How do i set local network number in IpNetworkBuilder?
-
BACnetTimeoutException: No response from instanceId and Unable to find router to network Unable to find router to network
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()); }