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

OSGiConsole outputs to where thread was started, not in current console window #1545

Closed
robnielsen opened this issue Jul 13, 2020 · 6 comments · Fixed by #2961
Closed

OSGiConsole outputs to where thread was started, not in current console window #1545

robnielsen opened this issue Jul 13, 2020 · 6 comments · Fixed by #2961
Labels
bug An unexpected problem or unintended behavior of the Core PR pending

Comments

@robnielsen
Copy link

The class org.eclipse.smarthome.io.console.karaf.internal.OSGiConsole prints to the output stream associated with the thread using System.out.print* methods. This can cause the results from console commands to potentially get displayed elsewhere. I have encountered this while trying to implement support to configure and monitor Insteon devices. An example of what is happening is:

  • user create a ssh session to OH
  • user send message to device from ssh session
  • device responds and is handled by OH daemon thread
  • output from console.println() appears where start.sh was ran, not ssh session

Ideally the output would show up in the console that sent the message. The workaround is to write stdout to a log file and monitor the log file while sending commands to a device. For example I use the following to stat up OH:

/opt/openhab/start.sh server >/opt/openhab/userdata/logs/console.log 2>&1 &

@robnielsen
Copy link
Author

The OH3 class is org.openhab.core.io.console.karaf.internal.OSGiConsole

@kaikreuzer
Copy link
Member

Interesting. Can you describe a case with any of the core console commands where this can be reproduced?

@robnielsen
Copy link
Author

This is currently happening with the Insteon binding smarthome:insteon start_monitoring console command. It will also happen as new configuration commands are added.

@kaikreuzer
Copy link
Member

I am not using Insteon and was hoping for a way to reproduce with a core console command.

@robnielsen
Copy link
Author

I use very few of the core commands. BTW, this worked just fine when I run it using the eclipse dev env.

@robnielsen
Copy link
Author

@kaikreuzer, here is a binding that reproduces the issue. The steps you can use to reproduce:

  • Build and install org.openhab.binding.hello-3.1.0-SNAPSHOT.jar
  • Install binding and create a Hello Binding Thing
  • Open a console window and enter hello start
  • You should see the message Should be printing 'hello' here...
  • hello [count] is output every second to the place that openHAB was started

You can enter the command hello stop to stop the printing of the hello message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core PR pending
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants