Error "502 Bad Gateway" when accessing Manager thru browser

I have followed the installation procedure available at https://openremote.io/get-started-manager/ to install the openremote in one Linux Ubuntu (Virtual Machine / Virtual Box), but after starting OpenRemote Manager from source-build images, with the two commands below, I´m getting the error “502 Bad Gateway” while accessing the service thru the browser.

root@openremote-manager:~/openremote# ./gradlew clean installDist
root@openremote-manager:~/openremote# docker-compose up --build

After executing the second command above, the terminal keeps showing the runtime logs of the Manager and other things. The message I´ve got in the runtime log, when the browser shows the error “502 Bad Gateway”, is:

manager_1 | 2021-01-02 05:41:01.113 INFO [WebService task-1 ] emote.container.web.WebServiceExceptions : Web service exception in 'Undertow Servlet Dispatch' for 'HttpServerExchange{ GET /main/}', root cause: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;

Up to the point where I got the error “java.lang.NoSuchMethodError”, everything seems to be working fine.

I´m struggling with the logs trying to find a clue one what is happening, no luck.

Some command outputs of the scenario:

root@openremote-manager:~/openremote# docker container ls --no-trunc
CONTAINER ID                                                       IMAGE                          COMMAND                                                                                                          CREATED          STATUS                    PORTS                                                              NAMES
79f1363a0cf87af3539f649cb25d0fbe7de8483ecb1f806b019eedccfda02178   openremote/proxy:latest        "/entrypoint.sh run"                                                                                             40 minutes ago   Up 40 minutes (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8883->8883/tcp   openremote_proxy_1
2d956d3f0c5d4ddc0c0cc38e5e3b0858da2bf742b9845be58a69a39a7198b811   openremote/manager:latest      "/bin/sh -c 'java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main'"   40 minutes ago   Up 40 minutes (healthy)   8080/tcp                                                           openremote_manager_1
7e56e4326d16b6485800a20de804e5b847148a79f2c1e0ffcda0b7d44137df9a   openremote/keycloak:latest     "/opt/jboss/docker-entrypoint.sh -b 0.0.0.0"                                                                     42 minutes ago   Up 42 minutes (healthy)   8080/tcp, 8443/tcp                                                 openremote_keycloak_1
9581c8a8f5f6b824481a179ee1fbb12b0f71b09c6565b0342ed6e021e4e626a0   openremote/postgresql:latest   "docker-entrypoint.sh postgres"                                                                                  42 minutes ago   Up 42 minutes (healthy)   5432/tcp                                                           openremote_postgresql_1

root@openremote-manager:~/openremote# ifconfig -a
br-62555f2f8170: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.24.0.1  netmask 255.255.0.0  broadcast 172.24.255.255
        inet6 fe80::42:e8ff:fe83:6f3  prefixlen 64  scopeid 0x20<link>
        ether 02:42:e8:83:06:f3  txqueuelen 0  (Ethernet)
        RX packets 733  bytes 110296 (110.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 171  bytes 36197 (36.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:68:95:a5:5b  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.16.13  netmask 255.255.255.0  broadcast 192.168.16.255
        inet6 2804:431:c7cd:4da2:d361:54cd:8a96:7c18  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::bd87:a29c:a194:9a4c  prefixlen 64  scopeid 0x20<link>
        inet6 2804:431:c7cd:4da2:54b5:d62f:ebad:af1a  prefixlen 64  scopeid 0x0<global>
        ether 08:00:27:e6:66:95  txqueuelen 1000  (Ethernet)
        RX packets 73469  bytes 43271534 (43.2 MB)
        RX errors 0  dropped 500  overruns 0  frame 0
        TX packets 48135  bytes 7587952 (7.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 12273  bytes 1133009 (1.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12273  bytes 1133009 (1.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth8d87abd: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2cc0:a6ff:fe62:ea90  prefixlen 64  scopeid 0x20<link>
        ether 2e:c0:a6:62:ea:90  txqueuelen 0  (Ethernet)
        RX packets 2087  bytes 354307 (354.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1354  bytes 442387 (442.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vetha092592: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::b050:91ff:fe40:dace  prefixlen 64  scopeid 0x20<link>
        ether b2:50:91:40:da:ce  txqueuelen 0  (Ethernet)
        RX packets 2889  bytes 1160029 (1.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4040  bytes 730219 (730.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethccdf540: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::30d0:ccff:fe8a:f268  prefixlen 64  scopeid 0x20<link>
        ether 32:d0:cc:8a:f2:68  txqueuelen 0  (Ethernet)
        RX packets 92  bytes 22912 (22.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 749  bytes 96293 (96.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethd064b4d: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::48bf:d4ff:fe5b:4b78  prefixlen 64  scopeid 0x20<link>
        ether 4a:bf:d4:5b:4b:78  txqueuelen 0  (Ethernet)
        RX packets 1949  bytes 381884 (381.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2306  bytes 834437 (834.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@openremote-manager:~/openremote# brctl show
bridge name     bridge id               STP enabled     interfaces
br-62555f2f8170         8000.0242e88306f3       no              veth8d87abd
                                                        vetha092592
                                                        vethccdf540
                                                        vethd064b4d
docker0         8000.02426895a55b       no

root@openremote-manager:~/openremote# docker exec -it 2d956d3f0c5d bash
root@2d956d3f0c5d:/deployment/manager# cat logging.properties | grep -i deploy
# /deployment/manager/logging.properties on the host machine, or
java.util.logging.FileHandler.pattern=/deployment/manager/logs/openremote.log
root@2d956d3f0c5d:/deployment/manager# cd logs/
root@2d956d3f0c5d:/deployment/manager/logs# ls -la
total 8
drwxr-xr-x 2 root root 4096 Jan  1 19:55 .
drwxr-xr-x 5 root root 4096 Jan  1 19:55 ..
root@2d956d3f0c5d:/deployment/manager/logs#

From another computer:
D:\>tcping -t 192.168.16.13 443

    ** Pinging continuously.  Press control-c to stop **

    Probing 192.168.16.13:443/tcp - Port is open - time=7.631ms
    Probing 192.168.16.13:443/tcp - Port is open - time=0.930ms
    Probing 192.168.16.13:443/tcp - Port is open - time=0.426ms
    Probing 192.168.16.13:443/tcp - Port is open - time=0.816ms
    Control-C

    Ping statistics for 192.168.16.13:443
         4 probes sent.
         4 successful, 0 failed.  (0.00% fail)
    Approximate trip times in milli-seconds:
         Minimum = 0.426ms, Maximum = 7.631ms, Average = 2.451ms

What is the URL in your browser you are calling?

What is the output of:

docker exec openremote_manager_1 env | grep IDENTITY_NETWORK_HOST

From the Ubuntu host (same one where I´ve installed the openremote):
https://localhost

which is redirected to:
[same link]/main (I´m saving link, as this issue platform permits me to send only two links in the response)

I´ve also tried out in the same VM machine where the openremote is, and from another in the same network (192.168.16.7 / Windows) :
https://192.168.16.13/main

and

[the same above]/?realm=smartcity

All of the the above URLs gave me the same result (“502 Bad Gateway”).

root@openremote-manager:~/openremote# docker exec openremote_manager_1 env | grep IDENTITY_NETWORK_HOST
IDENTITY_NETWORK_HOST=localhost

root@openremote-manager:~/openremote# telnet localhost 443
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^\Connection closed by foreign host.

Calling it with telnet is a brave move as it is very low TCP/IP emulation. What do you see after this?

curl -i -L --insecure localhost

Yes, you´re right. :slight_smile: This approach with curl checks also other network layers, indeed:

root@openremote-manager:~/openremote# curl -i -L --insecure localhost
HTTP/1.1 302 Found
content-length: 0
location: https://localhost/
cache-control: no-cache

HTTP/1.1 302 Found
location: http://localhost/main
content-length: 0
date: Sat, 02 Jan 2021 14:38:21 GMT

HTTP/1.1 302 Found
content-length: 0
location: https://localhost/main
cache-control: no-cache

HTTP/1.1 302 Found
location: /main/
content-type: text/html;charset=UTF-8
content-length: 64
date: Sat, 02 Jan 2021 14:38:21 GMT

HTTP/1.1 502 Bad Gateway
content-length: 107
cache-control: no-cache
content-type: text/html
connection: close

<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>

This is the startup log:

Sorry for sharing via Google Drive, this platform still doesn´t allow me to share files as my user is new.

This is strange. What I would propose to try is:

docker-compose down
docker volume prune
docker-compose up --no-build

Tried as stated, but got the same error (“502 Bad Gateway”).

root@openremote-manager:~/openremote# docker-compose down
Stopping openremote_proxy_1      ... done
Stopping openremote_manager_1    ... done
Stopping openremote_keycloak_1   ... done
Stopping openremote_postgresql_1 ... done
Removing openremote_proxy_1      ... done
Removing openremote_manager_1    ... done
Removing openremote_keycloak_1   ... done
Removing openremote_deployment_1 ... done
Removing openremote_postgresql_1 ... done
Removing network openremote_default
root@openremote-manager:~/openremote#
root@openremote-manager:~/openremote#
root@openremote-manager:~/openremote# docker-compose down
Removing network openremote_default
WARNING: Network openremote_default not found.
root@openremote-manager:~/openremote# docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
openremote_deployment-data
openremote_postgresql-data
openremote_proxy-data
openremote_zwave-data

Total reclaimed space: 244.4MB
root@openremote-manager:~/openremote# docker-compose up --no-build
Creating network "openremote_default" with the default driver
Creating volume "openremote_proxy-data" with default driver
Creating volume "openremote_deployment-data" with default driver
Creating volume "openremote_postgresql-data" with default driver
Creating volume "openremote_zwave-data" with default driver
Creating openremote_deployment_1 ... done
Creating openremote_postgresql_1 ... done
Creating openremote_keycloak_1   ... done
Creating openremote_manager_1    ... done

OK, let’s nuke local images and try to run the stack on the official ones.

docker-compose down
docker-compose pull
docker-compose up --no-build

Tried it, but got the same result. Should this second command return some output?

root@openremote-manager:~/openremote# docker-compose down
Stopping openremote_proxy_1      ... done
Stopping openremote_manager_1    ... done
Stopping openremote_keycloak_1   ... done
Stopping openremote_postgresql_1 ... done
Removing openremote_proxy_1      ... done
Removing openremote_manager_1    ... done
Removing openremote_keycloak_1   ... done
Removing openremote_postgresql_1 ... done
Removing openremote_deployment_1 ... done
Removing network openremote_default
root@openremote-manager:~/openremote# docker-compose pull
root@openremote-manager:~/openremote# docker-compose pull
root@openremote-manager:~/openremote# docker-compose up --no-build
Creating network "openremote_default" with the default driver
Creating openremote_deployment_1 ... done
Creating openremote_postgresql_1 ... done
Creating openremote_keycloak_1   ... done
Creating openremote_manager_1    ... done
<output ommited>
manager_1     | 2021-01-02 18:07:04.303  INFO    [WebService task-1             ] emote.container.web.WebServiceExceptions : Web service exception in 'Undertow Servlet Dispatch' for 'HttpServerExchange{ GET /main/}', root cause: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
manager_1     | 2021-01-02 18:07:12.726  INFO    [WebService task-1             ] emote.container.web.WebServiceExceptions : Web service exception in 'Undertow Servlet Dispatch' for 'HttpServerExchange{ GET /main/}', root cause: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;

One thing I´m trying to understand here is if command below is running accordingly.

Do you know how can I be sure it is finding the “org.openremote.manager.Main” and running it as expected?

root@openremote-manager:~# docker container ls --no-trunc
<output ommited>
ba93f24021ba5fef53a0ceea52a3ce8eefed85ae9c733b006a8d3feead6deca7   openremote/manager:latest      "/bin/sh -c 'java $JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main'"   7 minutes ago   Up 7 minutes (healthy)   8080/tcp  
<output ommited>
root@openremote-manager:~# docker exec -it ba93f24021ba bash
root@ba93f24021ba:/opt/app# cd lib/
root@ba93f24021ba:/opt/app/lib# ls -la | grep manager
-rw-r--r-- 1 root root   651775 Jan  1 10:43 openremote-manager-3.0.0.jar

It seems that is not pulling images from the docker hub. Remove the ones you’ve build yourself, i.e.

docker images -q | xargs docker rmi
docker-compose pull

You should see that images are downloading from the hub.

Michal, removed everything and reinstalled with the commands you´ve mentioned. No luck.

Just one thing I have not mentioned in the first description here (because I thought it was not relevant) is that my installation was performed by cloning the git, like this:

root@openremote-manager:~# git clone https://github.com/openremote/openremote.git
root@openremote-manager:~# cd openremote
root@openremote-manager:~/openremote# ./gradlew clean installDist
root@openremote-manager:~/openremote# docker-compose up --build

Michal,

I finally found what was the problem. I had not observed the JDK version installed, it was the 11.

All I did was to install version 8, as stated in the documetation, and proceeded with the commands below:

root@openremote-manager:~/openremote# ./gradlew clean installDist
root@openremote-manager:~/openremote# docker-compose up --build

Thank you very much for your support, and sorry for the mistake. This is my very first time in it, and I´ll go with the tests now.

Best Regards.

1 Like

This is a very good and valid point!

We have also a docker image with all tooling, which we use in our CI/CD pipeline. You can always use it instead, which means that it is not necessary to match versions in this case:

docker run --rm -v $(pwd):/or \
  registry.gitlab.com/openremote/openremote:master \
  ./gradlew clean installDist
1 Like