<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Unable to find router to network]]></title><description><![CDATA[<p dir="auto">I'm trying to connect to a BACNet device. The code I wrote for this looks somewhat like:</p>
<pre><code>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 = () -&gt; {
                    try {
                        DiscoveryUtils.getExtendedDeviceInformation(localDevice, remoteDevice);
                        SequenceOf&lt;ObjectIdentifier&gt; 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();
            }
        });

        localDevice.sendGlobalBroadcast(new WhoIsRequest());
    }
</code></pre>
<p dir="auto">The logging shows the following devices:<br />
iAm Received from device: 400, NetworkNumber: 0<br />
iAm Received from device: 401, NetworkNumber: 17436<br />
iAm Received from device: 402, NetworkNumber: 17436<br />
iAm Received from device: 404, NetworkNumber: 17436<br />
iAm Received from device: 500, NetworkNumber: 17436<br />
iAm Received from device: 501, NetworkNumber: 17436<br />
iAm Received from device: 502, NetworkNumber: 17436<br />
iAm Received from device: 0, NetworkNumber: 0<br />
iAm Received from device: 141, NetworkNumber: 0<br />
iAm Received from device: 200, NetworkNumber: 0<br />
iAm Received from device: 201, NetworkNumber: 16924<br />
iAm Received from device: 202, NetworkNumber: 16924</p>
<p dir="auto">When connection with an explorer I see that the 17436 network is behind the 400 device and the 16924 network behind the 200 device.</p>
<p dir="auto">I get the following errors when running this code.</p>
<ul>
<li>com.serotonin.bacnet4j.exception.BACnetTimeoutException: Unable to find router to network 17436</li>
<li>java.lang.RuntimeException: Invalid arguments: router address not provided for remote recipient Address [networkNumber=17436, macAddress=[1c,44,91,1,0,0]]</li>
</ul>
<p dir="auto">I bind the localDevice to to the BAC0 port on a specific ip adress on the machine this code is running on. The machine has 2 interfaces and the default gateway points to a machine on the other interface.</p>
<p dir="auto">I tried using port BAC1, however if I do that, I don't see the IAmReceived messages anymore. So the polling task will not start.</p>
<p dir="auto">Has anyone an idea what I'm doing wrong and how I can connect to that (foreign?) device?</p>
]]></description><link>https://forum.mango-os.com/topic/3114/unable-to-find-router-to-network</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Nov 2026 09:12:22 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/3114.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Nov 2017 15:33:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unable to find router to network on Fri, 09 Nov 2018 16:56:13 GMT]]></title><description><![CDATA[<p dir="auto">Hi davyv,</p>
<p dir="auto">Someone referenced this in another thread and so I thought I'd answer, even though it has been a very long time.</p>
<p dir="auto">My suspicion is that you're not seeing or the devices aren't sending the IAmRouterToNetwork messages. Most likely this has to do with them going to broadcast addresses and your having bound a specific address. So, the operating system may not be delivering those broadcasts to your LocalDevice. You could try binding the address <code>0.0.0.0</code> or just zeros in the subnet bits, like <code>192.168.0.0</code></p>
]]></description><link>https://forum.mango-os.com/post/20473</link><guid isPermaLink="true">https://forum.mango-os.com/post/20473</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Fri, 09 Nov 2018 16:56:13 GMT</pubDate></item></channel></rss>