Connect openems edge to a distant backend

Hello,

I’m trying to connect an openems edge device to and openems backend installed on a server out of the local network.
the server will works as a database and will be able to show the monitorig of edge devices
I’ve configured the server with nginx to make reverse proxy.

I can’t have a connexion between the edge device and the backend on the server.
i have the following error

2019-10-04 16:07:07,093 [read-493] INFO [socket.AbstractWebsocketClient] Websocket [ws://my_domain/openems-ws/] closed. Code [1002] Reason [Invalid status code received: 502 Status line: HTTP/1.1 502 Bad Gateway]

I have the following parameters on edge side

url : ws://my_domain/openems-ws/
proxy port 80

I have the followinf nginx config parapeters for websocket

  location /openems-ws/ {
  	proxy_http_version 1.1;
  	proxy_set_header Upgrade $http_upgrade;
  	proxy_set_header Connection "upgrade";

  	proxy_pass http://openems-ws/;
  	proxy_set_header Accept-Encoding "";

  	proxy_set_header Host $host;
  	proxy_set_header X-Real-IP $remote_addr;
  	proxy_set_header X-Forwarded-Host $host;
  	proxy_set_header X-Forwarded-Server $host;
  	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

anyone has an idea of the problem?

Hello,

I’m not familiar with nginx but in my apache2 config I had to proxy pass to ws://127.0.0.1:8078 (the port that is set in the backend configuration)

I hope that helps.

How did you configure the edge application to connect to the backend?
can you show me your apache config for the reverse proxy?

It seems my backend websocket is not available even on localhost
I have the following message when I run an edge app on the same machine

[​c​t​r​l​B​a​c​k​e​n​d​0​]​ ​E​r​r​o​r​:​ ​C​o​n​n​e​c​t​i​o​n​ ​r​e​f​u​s​e​d​ ​(​C​o​n​n​e​c​t​i​o​n​ ​r​e​f​u​s​e​d​)

the backend is configured to open port 8081 for edge app

Hi,

what you want to do? a proxy pass you will only need, if you want to have a secure communication…

normally your websocket runs on a port like 8082 (default)

and than the config would be more like this

proxy_pass http://localhost:8082;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";

if it is on the same machine, else of course not localhost.