Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Emulator getNetworkInterfaces #823

Closed
dwoodard1 opened this issue Nov 23, 2016 · 10 comments
Closed

Network Emulator getNetworkInterfaces #823

dwoodard1 opened this issue Nov 23, 2016 · 10 comments

Comments

@dwoodard1
Copy link
Contributor

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.

@dwoodard1 dwoodard1 added this to the KURA-2.1.0 milestone Nov 23, 2016
@cdealti
Copy link
Contributor

cdealti commented Nov 24, 2016

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
Copy link
Contributor

ctron commented Nov 28, 2016

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
Copy link
Contributor

cdealti commented May 26, 2017

@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
Copy link

hayrolr commented Oct 17, 2018

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
Copy link
Contributor

cdealti commented Oct 17, 2018

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

@hayrolr
Copy link

hayrolr commented Oct 17, 2018

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

@cdealti
Copy link
Contributor

cdealti commented Oct 18, 2018

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

@hayrolr
Copy link

hayrolr commented Oct 23, 2018

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,

Copy link
Contributor

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

@github-actions github-actions bot added the Stale label Nov 12, 2023
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants