# State refresh after changing an item

**URL:** <https://community.openhab.org/t/state-refresh-after-changing-an-item/86877>\
**Category:** Android App\
**Created:** [December 4, 2019, 2:08pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877 "2019-12-04T14:08:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 4, 2019, 2:08pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/1 "2019-12-04T14:08:06Z")

</div>

Hi all,

I set up a reverse proxy based on apache 2.4 which, after struggling with the config quite a long time, is working from the outside world by a public DNS server name as well as from the inside (LAN and local DNS server name).  
There is only one annoying thing which I tracked down to a timeout after POST, when using the SSL encrypted remote access. When I change, for example, a dimmable light the actual setting is not shown in the app until the proxy timeout occurs or when I change view in the app. It works like a charm if I am logged in to my WLAN an the local server URL is used.

As the http and https reverse proxy both use the same backend address [http://127.0.0.1](http://127.0.0.1):myOHport I was expecting both configurations to behave identically.

Comparing the apache logs only shows that the POST request, which sends the new setting to the item, returns immediately followed by a GET using http, while POST times out on HTTPS (or maybe the following GET which should fetch the new item state).

The local config looks like this

```csv
    <VirtualHost my.local.ip:80>
      ServerName my.local.servername
      ErrorLog /var/log/apache2/lerror.log
      CustomLog /var/log/apache2/access.log vhost_debug
      CustomLog /var/log/apache2/referer.log referer

      ProxyPass / http://127.0.0.1:8880/
      ProxyPassReverse / http://127.0.0.1:8880/

      <Location "/">
        AuthName openHAB
        AuthType Basic
        AuthBasicProvider file
        AuthUserFile /my/password/file

        <RequireAll>
          <RequireAny>
            Require ip my.local.net
          </RequireAny>

          <RequireAny>
            Require ip some.client.without.username
            Require ip other.client.without.username
            Require valid-user
          </RequireAny>
        </RequireAll>
      </Location>
    </VirtualHost>

```

The SSL config looks like this:

```csv
    <VirtualHost my.local.server.ip:443>
      ServerName my.public.servername
      ProxyPass / http://127.0.0.1:8880/
      ProxyPassReverse / http://127.0.0.1:8880/
      ProxyTimeout 30
      ProxyPreserveHost On
      SetEnv proxy-nokeepalive 1
      SSLProxyEngine on

      RequestHeader set X-Forwarded-Proto "https"
      Header edit Location ^http: https:

      ProxyHTMLEnable On
      LogLevel info
      ErrorLog /var/log/apache2/ssl_error.log
      CustomLog /var/log/apache2/ssl_access.log ssl_vhost_common
      CustomLog /var/log/apache2/ssl_referer.log referer

      SSLEngine On

      SSLCACertificateFile /my/ssl/cakey
      SSLCACertificatePath /my/ssl/cacrt
      SSLCertificateFile /my/openhab/serverkey
      SSLCertificateKeyFile /my/openhab/servercrt
      SSLCARevocationCheck chain no_crl_for_cert_ok
      SSLCARevocationPath /my/ssl/crl
      SSLCipherSuite HIGH:!aNULL:!MD5

      <Location "/">
        AuthName openHAB
        AuthType Basic
        AuthBasicProvider file
        AuthUserFile /my/openhab/pwfile

        SSLVerifyClient require
        SSLVerifyDepth 1

        <RequireAny>
          Require ip my.local.net
          Require valid-user

          <RequireAll>
            Require expr %{SSL_CLIENT_S_DN_OU} == 'my client OU'
            Require expr %{SSL_CLIENT_S_DN_O} == 'my client O'
          </RequireAll>

          <RequireAny>
            Require expr %{SSL_CLIENT_S_DN_CN} == 'user1'
            Require expr %{SSL_CLIENT_S_DN_CN} == 'user2'
            Require expr %{SSL_CLIENT_S_DN_CN} == 'user3'
            Require expr %{SSL_CLIENT_S_DN_CN} == 'user4'
          </RequireAny>
        </RequireAny>
      </Location>
    </VirtualHost>

```

The Basic UI shows the same behaviour. The Classic UI works as expected. Paper UI shows the same behaviour on the first change, every change on the same item after that results in “Error 400: Bad request”.

Checking a heating control item I saw that somehow the character encoding might be broken.

openhab.log:

```csv
2019-12-04 15:09:04.198 [WARN] [rest.core.internal.item.ItemResource] - Receive
d HTTP POST request at 'items/HeizkoerperAnbauKueche_4_SetTemperature' with an i
nvalid status value '18.9 Â°C'.
2019-12-04 15:14:35.447 [WARN] [rest.core.internal.item.ItemResource] - Receive
d HTTP POST request at 'items/HeizkoerperAnbauKueche_4_SetTemperature' with an i
nvalid status value '19.1 Â°C'.

```

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 9:27am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/2 "2019-12-11T09:27:42Z")

</div>

I guess it has to do with the rewriting but doubt anyone is willing to debug your `httpd.conf`.  
Move to `nginx`. openHABian comes with a working version of that, including config.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 9:47am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/3 "2019-12-11T09:47:03Z")

</div>

I don’t think I need anyone to debug my apache config files. I maintain several apache servers and I am quite familiar with configuring apache servers. I posted my config because most of the time the first question is “can you post your config”.

Can anyone confirm that reverse proxying with ssl and client certificates works with nginx? Especially concerning remote access and automatic update of the item values?

BTW: Everything, along with many other things like radius auth, samba server, dlna server, firewall, proxy, etc., is running on openSuSE Leap.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 9:51am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/4 "2019-12-11T09:51:19Z")

</div>

> [@Jogobo](#):
>
> Can anyone confirm that reverse proxying with ssl and client certificates works with nginx?

Not sure what you refer to but openHABian deploys nginx to include LetsEncrypt certificates.  
Many OH users including myself successfully use it.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 9:54am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/5 "2019-12-11T09:54:50Z")

</div>

I’m referring to the App settings “Fernzugriff (Remote Access?)” and “SSL-Client-Zertifikat (-certificate)”. I deploy my own client certificates from my own CA. I don’t need all the things openHABian deploys as I have most of the stuff up running for “ages”.

I would like to get a confirmation that running the App for Android, which accesses a reverse proxy based on nginx does not show the same behaviour that I described above.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 10:04am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/6 "2019-12-11T10:04:36Z")

</div>

> [@Jogobo](#):
>
> I’m referring to the App settings “Fernzugriff (Remote Access?)” and “SSL-Client-Zertifikat (-certificate)”.

Of course you do, but that’s no clear answer if you want help. Probably everybody of those to use nginx use it to get the app to access OH safely (which of course includes SSL thus a server cert).

> [@Jogobo](#):
>
> I would like to get a confirmation that running the App for Android, which accesses a reverse proxy based on nginx does not show the same behaviour that I described above.

But we’re not your vendor or personal support hotline that you may talk to in that manner.  
Sit down on your four letters, implement it and see for yourself. If you are as proficient in that stuff as you claim then that should be a snap, shouldn’t it.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 10:20am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/7 "2019-12-11T10:20:41Z")

</div>

I thought that, like you said, many others use a nginx based solution and that the work had already been done many times before. As you use it too I would have thought it to be much easier if you just open the App or access your Paper UI from a remote site, change a setting and confirm, that the changes to the item are visualized immediately in the App or Paper UI. That, in addition, would confirm it to be an issue with Apache and make it worth the time and the work to set up nginx in parallel to Apache.

As you can imagine it’s not that easy to set up a new web server in parallel to a complex virtual server environment just to find out what many users already found out before. I’m not a big fan of ressource wasting.

I am completely aware that this is not a personal support hotline. But I thought asking for knowledge and have benefit from the experiences of other users was a main purpose of these communities.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 10:32am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/8 "2019-12-11T10:32:06Z")

</div>

> [@Jogobo](#):
>
> I would have thought it to be much easier if you just open the App or access your Paper UI from a remote site, change a setting and confirm

I still don’t understand what you mean. Unless you refer to some exotic app you didn’t name, you don’t use **the** app to access PaperUI. That you would use a browser for. Or wouldn’t do that at all from remote if you’re serious about security.

> [@Jogobo](#):
>
> it’s not that easy to set up a new web server in parallel

I assume you mean proxy as you wouldn’t need another OH to be the web _server_.  
Guess what, it _is_ easy. openHABian source is on Github, just fetch what you need of it.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 11:00am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/9 "2019-12-11T11:00:37Z")

</div>

> [@mstormi](#):
>
> I still don’t understand what you mean. Unless you refer to some exotic app you didn’t name, you don’t use **the** app to access PaperUI.

Did you read **and** understand what the problem is? I tried to describe it in my first post in this thread. The official App as well as Paper UI and Basic UI show a similar (and faulty) behaviour in my configuration, while Classic UI works as expected.  
So it should not matter if someone tries it out with the App, Paper UI or Basic UI. If one of those does not show the faulty behaviour this would be a valuable hint in the right direction.

> [@mstormi](#):
>
> I assume you mean proxy as you wouldn’t need another OH to be the web _server_ .

No, I mean a web server as both, nginx and apache, are web servers with reverse proxy capability. And the first problem is that two web servers cannot listen on the same port on the same physical server. Second I have to open at least one non-standard port in my Router and in my firewall to gain access to a parallel nginx server instance from outside my LAN. All this with the risk of temporarily breaking access to the services running.  
Third problem is “openHABian is restricted to Debian/Ubuntu based systems”. As stated above I have an openSuSE Leap based system. Porting to openSuSE would not be helpful in matters of time and result.

A simple “works as expected” or “same issues” from someone who has a working system up and running would still be much simpler. I understand that openHABian is very good if you setup a new system on a supported platform but it’s not the answer for my question.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 11:22am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/10 "2019-12-11T11:22:31Z")

</div>

> [@Jogobo](#):
>
> Did you read **and** understand what the problem is?

I admit I had forgotten about when replying to the other post, but you were adding to the confusion by talking about PaperUI only in your next post, and PaperUI is wrong in the first place thus misleading anyway. You mustn’t use PaperUI for any user action such as to switch items. It’s an admin UI.

> [@Jogobo](#):
>
> No, I mean a web server as both, nginx and apache, are web servers with reverse proxy capability.

No, both are _software_. Apache is capable of providing both functions, to be a server and a proxy, but its server capabilities are NOT used in this context. The _server_ is a jetty which is part of OH.  
Meanwhile `nginx` can even not be setup to _serve_ (AFAIK - I admit I haven’t checked lately).  
So you meant to say a _proxy_ then.

> [@Jogobo](#):
>
> And the first problem is that two web servers cannot listen on the same port on the same physical server.

So what, use a different port then or bind them to a virtual IP.

> [@Jogobo](#):
>
> Second I have to open at least one non-standard port in my Router and in my firewall to …

So what ? Just do.

> [@Jogobo](#):
>
> Third problem is “openHABian is restricted to Debian/Ubuntu based systems”.

nginx is available as a SuSE package, too, and the config you can get to look up on openHABian repo on GitHub. Again, so what ?

> [@Jogobo](#):
>
> A simple “works as expected” or “same issues” from someone who has a working system up and running would still be much simpler.

The point is that if it had been a known problem unrelated to your specific proxying setup, this would have shown up much earlier for many users. It didn’t so it’s related to _your_ setup.  
And who do you expect to also have an Apache to have the same very specific configuration to do the URL proxy rewriting ?

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 11:27am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/11 "2019-12-11T11:27:51Z")

</div>

> [@mstormi](#):
>
> Who do you expect to also have an Apache with your very specific configuration to do the URL proxy rewriting ?

Another misunderstanding… I’m talking about a working openHABian/nginx based installation with SSL access. Maybe others don’t care if the change does not show up in UI as long as the changes are transmitted to the items. Maybe it’s a problem related to my special setup.  
To find out I am asking if my problem does not show in a setup you recommend.

As there is a difference in behaviour in my special configuration concerning Classic UI vs. Basic/Paper UI the problem might as well be UI specific.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 11:32am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/12 "2019-12-11T11:32:22Z")

</div>

> [@Jogobo](#):
>
> To find out I am asking if my problem does not show in a setup you recommend.

I usually don’t cite myself but here goes:

> [@mstormi](#):
>
> The point is that if it had been a known problem unrelated to your specific proxying setup, this would have shown up much earlier for many users. It didn’t so it’s related to _your_ setup.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 11:43am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/13 "2019-12-11T11:43:39Z")

</div>

Well, can’t say anything against your logic…

Maybe I’ll find the time to setup and test everything against nginx. Should be faster than asking anyone with an already configured system to tap on a light switch and observe the behaviour.

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [December 11, 2019, 11:47am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/14 "2019-12-11T11:47:14Z")

</div>

> [@Jogobo](#):
>
> As there is a difference in behaviour in my special configuration concerning Classic UI vs. Basic/Paper UI

This is something you can explore without extra setting up efforts. BasicUI and ClassicUI use very similar REST calls, unsurprising as they do essentially the same job. Can’t be much different.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 11:50am UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/15 "2019-12-11T11:50:34Z")

</div>

> [@Jogobo](#):
>
> Maybe I’ll find the time to setup and test everything against nginx.  
> Should be faster than asking anyone with an already configured system to tap on a light switch and observe the behaviour

No need. _I_ just did and behavior is as expected. Light switches on, virtual switch display state changes.  
No need for sarcasm either.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 12:03pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/16 "2019-12-11T12:03:39Z")

</div>

I already know the difference. Accessing my SSL secured webserver, which proxies the request to my 127.0.0.1 openhab instance:

1. Classic UI - Heating Control - Button up  
New temperature is immediately shown in UI, command (according to events.log) is sent to item

2. Basic UI - Heating Control - Button up  
Command (according to events.log) is sent to item, temperature in UI unchanged, after timeout (configured for the proxy) message on the bottom of the UI “Offline: waiting for connection”  
Message disappears (Basic UI online again), new temperature is shown (first change like this: “19,00 Â°C”, every other change correct)

Classic UI shows physically changed items immediately, Basic UI comes up with the bottom message every 30 seconds and then, after being online again, shows actual values.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 12:04pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/17 "2019-12-11T12:04:16Z")

</div>

Sorry, meant a dimmable light where % should change accordingly.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [December 11, 2019, 12:17pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/18 "2019-12-11T12:17:44Z")

</div>

> [@Jogobo](#):
>
> Sorry, meant a dimmable light where % should change accordingly.

Same there.

> [@Jogobo](#):
>
> Basic UI - Heating Control - Button up

Same there, no matter if BasicUI or app.  
I have seen the browser failing to refresh at times, but that’s browser dependent and a page reload always does.

---

<div class="post-metadata">

**Author:** ![Jogobo](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/2acd7d/32.png) [@Jogobo](https://community.openhab.org/u/Jogobo)\
**Post date:** [December 11, 2019, 12:24pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/19 "2019-12-11T12:24:40Z")

</div>

More surprisingly, when using a VPN connection and using the local webserver on port 80, which proxies to the same openhab instance at 127.0.0.1, Basic UI works as expected (as well as Paper UI and the App). No “Offline” messages at the bottom of the page, no “strange” characters in the values.

---

<div class="post-metadata">

**Author:** ![mueller-ma](https://community.openhab.org/user_avatar/community.openhab.org/mueller-ma/32/12448_2.png) [@mueller-ma](https://community.openhab.org/u/mueller-ma)\
**Post date:** [December 11, 2019, 2:34pm UTC](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877/20 "2019-12-11T14:34:56Z")

</div>

There’s a thread about ssl client cert and nginx: [Using NGINX Reverse Proxy for client certificate authentication - start discussion](https://community.openhab.org/t/using-nginx-reverse-proxy-for-client-certificate-authentication-start-discussion/43064)

I guess you really want to have ssl client certs and not just username and password?

[Next page](https://community.openhab.org/t/state-refresh-after-changing-an-item/86877.md?page=2)
