sap-labs-france / ev-server

The Open e-Mobility Charging Station management backend server (check also ev-dashboard and ev-mobile)
https://open-e-mobility.fr/
Apache License 2.0
141 stars 132 forks source link

Can i use ws and wss simultaneously? #4217

Closed samarasdelta closed 7 months ago

samarasdelta commented 10 months ago

Does anyone know if I can use ws and wss at the same time?

Server is configured and running on https.

Μy config.json file on the server side looks like this:

{
  "type": "ocpp",
  "implementation": "json",
  "protocol": "wss",
  "host": "samarasdelta.bio",
  "port": 8010,
  "keepaliveinterval": 30,
  "debug": true
},
{
  "type": "ocpp",
  "implementation": "json",
  "protocol": "ws",
  "host": "samarasdelta.bio",
  "port": 8011,
  "debug": true
}

So far, I've tested it with two simulators (one for ws protocol and one for wss) and haven't been able to reach a solution.

Both simulators can connect to the server, but only one of them can start a charging session.

Part of my etc/hosts file (windows) bellow:

127.0.0.1   samarasdelta.bio
::1 samarasdelta.bio

127.0.0.1   test.samarasdelta.bio
::1 test.samarasdelta.bio

Any reply would be greatly appreciated :)

PS: I'm using version 2.4.66 (ev-server & ev-dashboard)

samarasdelta commented 9 months ago

The answer is YES, the problem is that I'm trying to switch from one connection to another and I'm keep getting errors like this one bellow:

at new URL (internal/url.js:319:5)
at initAsClient (/home/ubuntu/ev-server/node_modules/ws/lib/websocket.js:502:17)
at new WebSocket (/home/ubuntu/ev-server/node_modules/ws/lib/websocket.js:71:7)
at WSClient.open (/home/ubuntu/ev-server/dist/webpack:/src/client/websocket/WSClient.ts:49:15)
at new WSClient (/home/ubuntu/ev-server/dist/webpack:/src/client/websocket/WSClient.ts:45:10)
at Promise (/home/ubuntu/ev-server/dist/webpack:/src/client/ocpp/json/JsonRestChargingStationClient.ts:121:27)
at Promise._execute (/home/ubuntu/ev-server/node_modules/bluebird/js/release/debuggability.js:384:9)
at Promise._resolveFromExecutor (/home/ubuntu/ev-server/node_modules/bluebird/js/release/promise.js:518:18)
at new Promise (/home/ubuntu/ev-server/node_modules/bluebird/js/release/promise.js:103:10)
at JsonRestChargingStationClient.openConnection (/home/ubuntu/ev-server/dist/webpack:/src/client/ocpp/json/JsonRestChargingStationClient.ts:102:18) input: 'null/REST/60af3c96490af47d011f5bd7/CS-SIEMENS>

is there any possible solution to this?

samarasdelta commented 7 months ago

If anyone is interested, I managed to make wss and ws protocols existing with nginx simultaneously by redirecting all ws connections to the wss. Pretty simple solution, although it seems very stable. I've been a testing a while now and everything seems to be ok. If anyone wants any help feel free to contact!