Can't change Items via the Remote URL in Android App

Tags: #<Tag:0x00007f6179a07508> #<Tag:0x00007f6179a07378> #<Tag:0x00007f6179a07210>

Hello everyone,

After successfully installing an nginx reverse proxy in my home network, I managed to set up everything for accessing my already running openHAB instance from the internet.

The subdomain openHAB is running on is protected by .htaccess username and password, directly in the nginx settings.
From any Browser I can now access https://openhab.my-domain.de, enter my credentials and see and control my sitemap without any problems. This works on my Desktop PC and my Android Phone both with Firefox and Chrome browsers.

In the Android App I can also set https://openhab.my-domain.de as the “Remote Server URL” and supply my Username and Password. This also works, it is connecting to my openHAB installation via the remote URL. I can see the sitemap as usual.
But if I try to change a switch for example, which should turn on the light, nothing happens in my home. The switch Item in the sitemap shows the ON state, but it does not turn on anything. In the openhab events.log nothing is received. And as soon as I refresh the sitemap on my smartphone in the App (by pulling down) the switch state shows OFF again.
If I turn on the light via the local URL on the Desktop PC in my browser, it works normally and the change is instantly visible in the openHAB App connected to the remote URL.
If I then try to turn it off from the App, it’s the same problem.

Have I missed something obvious in some config options or could this potentially be a bug?

Thanks for helping!
Marcell

what about the nginx access.log and error.log files ? you should be able to see all requests resp. rejected requests in these files.

My nginx error.log does not contain anything related to this.
The nginx access.log shows these two lines whenever I try to switch the Item from the App:

[13/Oct/2020:09:44:59 +0000] "POST /rest/items/shelly_wz1_power HTTP/1.1" 301 162 "-" "openHAB client for Android" "-"
[13/Oct/2020:09:44:59 +0000] "GET /rest/items/shelly_wz1_power HTTP/2.0" 200 272 "-" "openHAB client for Android" "-"

shelly_wz1_power is the Item I tried to switch from the App.

Here is the nginx access.log when I try the same from my Windows 10 PC:

[13/Oct/2020:09:52:14 +0000] "POST /rest/items/shelly_wz1_power HTTP/2.0" 200 0 "https://openhab.*<my-domain.de>*/basicui/app?w=00&sitemap=home2" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" "-"

So I guess it has to be an issue with my nginx configuration?

What about the columns before the date in the nginx log file ?
Is the username for both entries ( working one and not working one ) the same ?
I am not sure if the OH app is able to handle .htaccess authentication.
For a test you may turn it off and e.g. use a rule on your routers firewall to only allow your phone to get in.

The two columns before Date/Time state the external IP (of phone or PC) and the username which is used for the .htacces authetication. Both are correct, that’s why I removed them from the post above.

If the Android App couldn’t handle the authentication, it wouldn’t be even able to show the Sitemap or not?
That’s the strange thing: I can see the sitemap, see when items states change, but can’t change anything from the App.
For a test I canged the .htaccess Password in the nginx Reverse Proxy, but not in my Phone:
The openHAB App gives an HTTP 401 Authentication failed error now.
After I set the correct password in the App again, everything is like before. So to me it seems that the Authentication isn’t the problem, but please correct me if you know better!

Yes, this assumption is correct.

This log line says that there’s an authentication issue: HTTP code 301 is returned by the server.

Which app version are you using?

I have the openHAB Android App version 2.15.0

Meanwhile I tried the myopenhab.org Cloud Connector which works without any problems.
The advantage of this solution is obviously that I don’t need the reverse proxy for it anymore, and there is the possibility of receiving notifications too. So I think I’ll stick with this solution for now.

But please tell me, if I should try anything, which could fix my initial problem.