OpenHab 2 HTTP(S) Port with Beta 5 Release

Hi, I am switching from openhab 1.x to openHab 2.0 Beta 5. But I have the need to change the HTTP and HTTPS port of the installation. But I cant figure out, how to do it…

This is my setup:

Ubuntu Server 14.04
openhab 2.0 Beta 5 installed via apt-get

This is what i tried already:

No matter what I do, the service is always started with the default 8080 and 8443 port. This is how it looks when I do a ps-ef | grep openhab

openhab 30356 30256 99 15:22 ? 00:00:07 /usr/lib/jvm/java-8-oracle/jre/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/lib/openhab2/config -Dorg.osgi.service.http.port=8080 -Dorg.osgi.service.http.port.secure=8443 -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/lib/openhab2/config -Dorg.osgi.service.http.port=8080 -Dorg.osgi.service.http.port.secure=8443 -Djava.awt.headless=true -XX:+UseG1GC -Djava.awt.headless=true -XX:+UseG1GC -Djava.endorsed.dirs=/usr/lib/jvm/java-8-oracle/jre/jre/lib/endorsed:/usr/lib/jvm/java-8-oracle/jre/lib/endorsed:/usr/share/openhab2/runtime/lib/endorsed -Djava.ext.dirs=/usr/lib/jvm/java-8-oracle/jre/jre/lib/ext:/usr/lib/jvm/java-8-oracle/jre/lib/ext:/usr/share/openhab2/runtime/lib/ext -Dkaraf.instances=/usr/share/openhab2/runtime/instances -Dkaraf.home=/usr/share/openhab2/runtime -Dkaraf.base=/var/lib/openhab2 -Dkaraf.data=/var/lib/openhab2 -Dkaraf.etc=/var/lib/openhab2/etc -Dkaraf.restart.jvm.supported=true -Djava.io.tmpdir=/var/lib/openhab2/tmp -Djava.util.logging.config.file=/var/lib/openhab2/etc/java.util.logging.properties -Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -classpath /usr/share/openhab2/runtime/lib/boot/org.apache.karaf.diagnostic.boot-4.0.8.jar:/usr/share openhab2/runtime/lib/boot/org.apache.karaf.jaas.boot-4.0.8.jar:/usr/share/openhab2/runtime/lib/boot/org.apache.karaf.main-4.0.8.jar:/usr/share/openhab2/runtime/lib/boot/org.osgi.core-6.0.0.jar org.apache.karaf.main.Main

Maybe I am missing somthing obvious here… I need someone to point me in the right direction. Any help is greatly apreciated.

Thanks
R.

How are you setting the environment variables?

I don’t know Ubuntu, but if it uses systemd then try adding the following to the service file or, as I have done, to an override file e.g. /etc/systemd/system/openhab.service.d/override.conf
> [Service]
Environment="OPENHAB_HTTP_PORT=8095"
Environment=“OPENHAB_HTTPS_PORT=8443”

I see the correct parameters in the commend that is executed, however I have yet to gain access tot he http server so take this with a pinch of salt.

I’ve given up trying to do it the “proper” way and instead simply edit /usr/share/openhab2/runtime/bin/setenv

That certainly works, but needs to be re-done with each update, as the file is overwritten

Dan

That’s the benefit of the systemd override, it will survive an update.
Got mine working now, so can confirm it is an option.

Mike.

You should be able to set the following in /etc/default/openhab2, which is a conffile and won’t get overriden each time.

EXTRA_JAVA_OPTS=""
OPENHAB_HTTP_PORT=8095
OPENHAB_HTTPS_PORT=8443

Thx for the tip. Right now this is the only way that works. I can’t figure out, why its not working with the environment variables. But the openHab start just wont pick it up… :worried:

Same here. I set the port to 8090 in /usr/share/openhab2/runtime/bin/setenv because I have Kodi running and this us already using port 8080. Can’t get the ports to change otherwise.

@reinhard_vornholt and @Marijn_Oudijk, Are you sure it’s not working when you set /etc/default/openhab2 as I mention above?

Yes I am.
I put this part of the setenv script into a seperate shell script (added the echo):

if [ ! -z ${OPENHAB_HTTP_PORT} ]; then HTTP_PORT=${OPENHAB_HTTP_PORT}
else
HTTP_PORT=8080
fi

echo $HTTP_PORT

When I execute it, it gives me the desired port number. I don’t know why it’s not working with openhab2. I guess it’s some kind of user rights. Looks to me, that the openhab user can’t “see” the environment variables at startup. But thats just a guess.

Same here. Not working.

Workaround is using setenv which is fine for the time being

I thought that might be it, but get the same result if I run openhab as root. So can’t be a permissions issue.

Perhaps some subtle bug in the setenv script?

Same problem here with raspbian jessie.

Unfortunately I still have the same problems after upgrading to OH2 final version. :frowning:

my brilliant solution was to change the ports on my other application and let openHAB have ports 8080 and 8443 to itself!