eclipse-kura / kura

Eclipse Kura™ is a versatile framework to supercharge your edge devices, streamlining the process of configuring your gateway, connecting sensors, and IoT devices to seamlessly collect, process, and send data to the cloud.
https://eclipse.dev/kura/
Eclipse Public License 2.0
499 stars 306 forks source link

Network Emulator getNetworkInterfaces #823

Closed dwoodard1 closed 10 months ago

dwoodard1 commented 7 years ago

The network emulator bundle uses java.net.NetworkInterface.getNetworkInterfaces() for retrieving a list of network interfaces. This method has a shortcoming in that it only returns configured interfaces. Interfaces that have not been configured are not returned. This is not ideal for those using the "no networking" versions of Kura. The emulator getNetworkInterfaces() method should be updated to use standard Linux utilities (ip, etc.) to retrieve network interface information.

cdealti commented 7 years ago

To me, on Linux, this happens if the Ethernet interface has no link (cable unplugged) disregarding if the interface is configured or not. Plugging the Ethernet cable is enough as a workaround.

Emulator bundles should be pure Java. For example I believe they are used in the Windows port @malikm

ctron commented 7 years ago

I agree that the emulator bundle should be capable of running on all platforms.

I could imagine however that the emulator bundle does not use any network interfaces at all. Just uses a dummy set of interfaces. Like the other emulator bundles do.

cdealti commented 7 years ago

@dwoodard1: This is a total mess. Background:

The only need for all this is the auto-configuration of the MQTT client ID from the MAC address of the primary network interface whose name is different on the Mac, Windows and Linux. On Linux this is further complicated by the Consistent Network Device Naming

Kura first checks the value of kura.primary.network.interface in kura.properties. If this is not set, like when Kura is run from the Eclipse emulator, the name of the primary network interface is determined through these dirty hacks which should be removed as they are OS-specific. Also note how these only work for Mac and Windows users. Linux users will experience two major problems:

  1. They do not have the "eth0" network interface (see link above)
  2. The Ethernet link is down (cable disconnected)

In both cases the MAC address of the primary network interface returned by the SystemService will be null and the MQTT client ID will not be auto-configured. As a result Kura will not attempt to connect to the MQTT broker. This is not shown in the Web UI, only in the Kura log.

One option is to move the OS specific code for Mac and Windows from the SystemService to the net.emulator, adding the code for Linux. This is not ideal though and you still have the problem 1) above (Linux Consistent Network Device Naming).

Another option is to remove the OS specific code entirely and add a warning in the Web UI if the MQTT client ID cannot be auto-configured and it must then be manually entered. In practice this should only be needed from the Kura emulator.

About NN installers, they only support Linux (RPI, Beaglebone etc). I believe we could replace org.eclipse.kura.emulator.net with org.eclipse.kura.linux.net in the distrib and it should always work.

hayrolr commented 5 years ago

So, is there a solution or workaround for this?.. I mean, I am simply running the Kura Emulator inside Eclipse and the error appears always, in the console/log, when starting the platform.

I am using my CentOS 7 and connecting or disconnecting the network cable link does not make any difference.

Regards,

cdealti commented 5 years ago

what is the name of the network interface in your CentOS box?

hayrolr commented 5 years ago

It's enp0s25. screenshot from 2018-10-17 09-29-23

cdealti commented 5 years ago

any luck assigning kura.primary.network.interface=enp0s25 in the kura.properties file in the emulator project?

hayrolr commented 5 years ago

It works if I set kura.primary.network.interface=enp0s25 in the kura.properties for the Emulator project... but only when I have the network cable linked, otherwise it fails with this exception:

12:41:00,830 [Component Resolve Thread] INFO MqttDataTransport:170 - Activating org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport... 12:41:00,840 [Component Resolve Thread] ERROR MqttDataTransport:804 - Invalid configuration 12:41:00,841 [Component Resolve Thread] ERROR MqttDataTransport:197 - Invalid client configuration. Service will not be able to connect until the configuration is updated java.lang.IllegalStateException: Invalid MQTT client configuration at org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport.buildConfiguration(MqttDataTransport.java:805) at org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport.activate(MqttDataTransport.java:195) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) .... at java.lang.Thread.run(Thread.java:748) Caused by: org.eclipse.kura.KuraException: The configuration attribute clientId is required and no value has been specified. at org.eclipse.kura.core.util.ValidationUtil.notEmptyOrNull(ValidationUtil.java:34) at org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport.buildConfiguration(MqttDataTransport.java:726)

Regards,

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 10 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.