apostoldevel / ocpp-cs

OCPP Central System and Charge Point emulator.
https://ocpp-css.com
MIT License
52 stars 15 forks source link

Docker: Token 404 Not Found OCPP Central System #4

Closed magadan closed 2 years ago

magadan commented 2 years ago

Hello, trying to test your software. Im getting :

token 404 Not Found OCPP Central System

On the default docker installation.

ufocomp commented 2 years ago

Hello!

Thanks for your feedback. The bug has been fixed. Please update source codes.

Good luck.

magadan commented 2 years ago

Ok, testing now with 'Dockerfile'. First tried i used docker image (docker run).

magadan commented 2 years ago

Hello, i clone the repo and build docker... Same error, Docker log its ok, i think is some related with oauth2 authentication, is possible to disable ?

import 'firebase/';

(anônimo) @ 9.59ab8d6f.chunk.js:2 main.b693a904.chunk.js:1 Token: Not present main.b693a904.chunk.js:1 CredentialsToken: Init - new req oauth2/token:1 Failed to load resource: the server responded with a status of 404 (Not Found) ocpp:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 main.b693a904.chunk.js:1 --> API /ChargePointList {} Headers ocpp:1 Failed to load resource: the server responded with a status of 404 (Not Found) manifest.json:1 Failed to load resource: the server responded with a status of 404 (Not Found) Falha no carregamento do mapa de origem pelo DevTools: Não foi possível carregar o conteúdo de http://192.168.3.13:9220/loader.css.map: Erro HTTP: código de status 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE localhost:9220/api/v1/ChargePointList:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

========================== DOCKER LOG

[2022/06/13 23:48:45] OCPP Central System version: 1.0.53ee764-b1 (release build)

[2022/06/13 23:48:46] [CP-A0000001] Configuration file: /etc/cs/cp/CP3/configuration.json

[2022/06/13 23:48:46] [CP-A0000002] Configuration file: /etc/cs/cp/CP4/configuration.json

[2022/06/13 23:48:46] [EM-A0000002] Configuration file: /etc/cs/cp/CP2/configuration.json

[2022/06/13 23:48:46] [EM-A0000001] Configuration file: /etc/cs/cp/CP1/configuration.json

[2022/06/13 23:48:46] [CP-A0000001] Trying connect to ws://localhost:9220/ocpp/786cb831a5a1c5636ba10cf960717fd34c280f63/CP-A0000001.

[2022/06/13 23:48:46] [CP-A0000002] Trying connect to ws://localhost:9220/ocpp/786cb831a5a1c5636ba10cf960717fd34c280f63/CP-A0000002.

[2022/06/13 23:48:46] [EM-A0000002] Trying connect to ws://localhost:9220/ocpp/EM-A0000002.

[2022/06/13 23:48:46] [127.0.0.1:46920] Connected.

[2022/06/13 23:48:46] [127.0.0.1:46922] Connected.

[2022/06/13 23:48:46] [EM-A0000001] Trying connect to ws://localhost:9220/ocpp/EM-A0000001.

[2022/06/13 23:48:46] [127.0.0.1:46924] Connected.

[2022/06/13 23:48:46] [CP-A0000001] [127.0.0.1:46920] OCPP client connected.

[2022/06/13 23:48:46] [127.0.0.1:46926] Connected.

[2022/06/13 23:48:46] [CP-A0000002] [127.0.0.1:46922] OCPP client connected.

[2022/06/13 23:48:46] [EM-A0000002] [127.0.0.1:46924] OCPP client connected.

[2022/06/13 23:48:46] [EM-A0000001] [127.0.0.1:46926] OCPP client connected.

[2022/06/13 23:48:48] [CP-A0000001] [51b57bd0996c40c238498a96b5de9bd3] [BootNotification] [Call] {"chargePointModel": "CP_EM", "chargePointVendor": "Apostol", "chargePointSerialNumber": "202111140003", "firmwareVersion": "1.0.0.1"}

[2022/06/13 23:48:48] [CP-A0000001] [51b57bd0996c40c238498a96b5de9bd3] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.969Z", "interval": 60}

[2022/06/13 23:48:48] [CP-A0000002] [01df858c56844004ab7d630261309e14] [BootNotification] [Call] {"chargePointModel": "CP_EM", "chargePointVendor": "Apostol", "chargePointSerialNumber": "202111140004", "firmwareVersion": "1.0.0.1"}

[2022/06/13 23:48:48] [CP-A0000002] [01df858c56844004ab7d630261309e14] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.969Z", "interval": 60}

[2022/06/13 23:48:48] [EM-A0000002] [ce70903b62b07f9fa23c4a2d157fa0fd] [BootNotification] [Call] {"chargePointModel": "CP_EM", "chargePointVendor": "Apostol", "chargePointSerialNumber": "202111140002", "firmwareVersion": "1.0.0.1"}

[2022/06/13 23:48:48] [EM-A0000002] [ce70903b62b07f9fa23c4a2d157fa0fd] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.970Z", "interval": 60}

[2022/06/13 23:48:48] [CP-A0000001] [51b57bd0996c40c238498a96b5de9bd3] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.969Z", "interval": 60}

[2022/06/13 23:48:48] [EM-A0000001] [2729b7487bc5a9745ff5a0ff0ef8008c] [BootNotification] [Call] {"chargePointModel": "CP_EM", "chargePointVendor": "Apostol", "chargePointSerialNumber": "202111140001", "firmwareVersion": "1.0.0.1"}

[2022/06/13 23:48:48] [EM-A0000001] [2729b7487bc5a9745ff5a0ff0ef8008c] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.970Z", "interval": 60}

[2022/06/13 23:48:48] [CP-A0000001] [5034017d868dd79faf87ee7996732782] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.970Z", "connectorId": 1}

[2022/06/13 23:48:48] [CP-A0000001] [5034017d868dd79faf87ee7996732782] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.970Z", "connectorId": 1}

[2022/06/13 23:48:48] [CP-A0000001] [5034017d868dd79faf87ee7996732782] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [CP-A0000001] [d5f6f9d5602b35036591a147a3c7501e] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.971Z", "connectorId": 2}

[2022/06/13 23:48:48] [CP-A0000001] [d5f6f9d5602b35036591a147a3c7501e] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.971Z", "connectorId": 2}

[2022/06/13 23:48:48] [CP-A0000001] [d5f6f9d5602b35036591a147a3c7501e] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [CP-A0000001] [0e809f3b3efeabcc10e7cc852c750283] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.971Z", "connectorId": 3}

[2022/06/13 23:48:48] [CP-A0000002] [01df858c56844004ab7d630261309e14] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.969Z", "interval": 60}

[2022/06/13 23:48:48] [CP-A0000001] [0e809f3b3efeabcc10e7cc852c750283] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.971Z", "connectorId": 3}

[2022/06/13 23:48:48] [CP-A0000001] [0e809f3b3efeabcc10e7cc852c750283] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [CP-A0000002] [d93165b418ca7949fcd81543a551764d] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.972Z", "connectorId": 19190498}

[2022/06/13 23:48:48] [EM-A0000002] [ce70903b62b07f9fa23c4a2d157fa0fd] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.970Z", "interval": 60}

[2022/06/13 23:48:48] [CP-A0000002] [d93165b418ca7949fcd81543a551764d] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.972Z", "connectorId": 19190498}

[2022/06/13 23:48:48] [CP-A0000002] [d93165b418ca7949fcd81543a551764d] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [EM-A0000002] [b03a5e55428634af08763d582c4b2138] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.972Z", "connectorId": 19170129}

[2022/06/13 23:48:48] [EM-A0000001] [2729b7487bc5a9745ff5a0ff0ef8008c] [BootNotification] [CallResult] {"status": "Accepted", "currentTime": "2022-06-13T23:48:48.970Z", "interval": 60}

[2022/06/13 23:48:48] [EM-A0000002] [b03a5e55428634af08763d582c4b2138] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.972Z", "connectorId": 19170129}

[2022/06/13 23:48:48] [EM-A0000002] [b03a5e55428634af08763d582c4b2138] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [EM-A0000001] [6659693b41b16148ed859ed94c91717e] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.973Z", "connectorId": 1}

[2022/06/13 23:48:48] [EM-A0000001] [6659693b41b16148ed859ed94c91717e] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.973Z", "connectorId": 1}

[2022/06/13 23:48:48] [EM-A0000001] [6659693b41b16148ed859ed94c91717e] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [EM-A0000001] [936a3136698056e4035139aaeccdf9e8] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.973Z", "connectorId": 2}

[2022/06/13 23:48:48] [EM-A0000001] [936a3136698056e4035139aaeccdf9e8] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.973Z", "connectorId": 2}

[2022/06/13 23:48:48] [EM-A0000001] [936a3136698056e4035139aaeccdf9e8] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:48] [EM-A0000001] [8c9afa26bafe9d01d220a67260ce173f] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.974Z", "connectorId": 3}

[2022/06/13 23:48:48] [EM-A0000001] [8c9afa26bafe9d01d220a67260ce173f] [StatusNotification] [Call] {"status": "Available", "errorCode": "NoError", "timestamp": "2022-06-13T23:48:48.974Z", "connectorId": 3}

[2022/06/13 23:48:48] [EM-A0000001] [8c9afa26bafe9d01d220a67260ce173f] [StatusNotification] [CallResult] {}

[2022/06/13 23:48:49] [CP-A0000001] [0605b1f46b32b137ab8a6e87ccaa2221] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [CP-A0000001] [0605b1f46b32b137ab8a6e87ccaa2221] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [CP-A0000001] [0605b1f46b32b137ab8a6e87ccaa2221] [Heartbeat] [CallResult] {"currentTime": "2022-06-13T23:48:49.950Z"}

[2022/06/13 23:48:49] [CP-A0000002] [0dff290980ddb0553c3e871a5d36ce68] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [CP-A0000002] [0dff290980ddb0553c3e871a5d36ce68] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [CP-A0000002] [0dff290980ddb0553c3e871a5d36ce68] [Heartbeat] [CallResult] {"currentTime": "2022-06-13T23:48:49.950Z"}

[2022/06/13 23:48:49] [EM-A0000002] [6266eb549d2ba3c523626243ceceb1d2] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [EM-A0000002] [6266eb549d2ba3c523626243ceceb1d2] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [EM-A0000002] [6266eb549d2ba3c523626243ceceb1d2] [Heartbeat] [CallResult] {"currentTime": "2022-06-13T23:48:49.950Z"}

[2022/06/13 23:48:49] [EM-A0000001] [1aab00b30f887c9621ddae59f5554d92] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [EM-A0000001] [1aab00b30f887c9621ddae59f5554d92] [Heartbeat] [Call] {}

[2022/06/13 23:48:49] [EM-A0000001] [1aab00b30f887c9621ddae59f5554d92] [Heartbeat] [CallResult] {"currentTime": "2022-06-13T23:48:49.951Z"}

[2022/06/13 23:48:56] [192.168.3.3:57279] Connected.

[2022/06/13 23:48:56] [192.168.3.3:57280] Connected.

[2022/06/13 23:48:56] [192.168.3.3:57281] Connected.

[2022/06/13 23:49:00] [192.168.3.3:57297] Connected.

[2022/06/13 23:50:59] [192.168.3.3:57280] Disconnected.

[2022/06/13 23:51:14] [192.168.3.3:57297] Disconnected.

ufocomp commented 2 years ago

Hello!

In docker settings, OAuth2 authorization is disabled.

Your container settings should be like this:

  1. Run the container cs.
  2. docker exec -it cs bash
  3. cat /opt/cs/CMakeLists.txt | grep WITH_AUTHORIZATION

Result:

set(WITH_AUTHORIZATION OFF CACHE BOOL "Build with authorization")
if (WITH_AUTHORIZATION)
    add_compile_options("-DWITH_AUTHORIZATION")

Valid value: WITH_AUTHORIZATION OFF

  1. cat /opt/cs/www/web/config.js | grep confAuthorize

    Result:

    confAuthorize: false,

Valid value: confAuthorize: false

Please check your web shell path settings (this is the cause of the 404 error)

  1. cat /etc/cs/sites/default.json

Result:

{
  "hosts": ["localhost:9220"],
  "root": "/opt/cs/www/web"
}

Valid value: /opt/cs/www/web

  1. ls -l /opt/cs/www/

Result:

drwxr-xr-x 2 root root 4096 Jun 13 15:50 docs
drwxrwxr-x 1 root root 4096 Jun 13 15:48 web

Make sure the web folder exists and is not empty.

magadan commented 2 years ago

Hello, I checked, the docker image available not has the /opt/cs/sites directory and default.json

I created by hand and restart, no lucky yet.

thank you.

magadan commented 2 years ago

p: i tried to install froum source too, but in the libdelphi i got "no target" to finish installation to /usr/local/lib ...

ufocomp commented 2 years ago

Hello!

The configuration files are located in: /etc/cs

Do you need a file:

/etc/cs/sites/default.json

Before building the application from source codes, you need to run the file ./configure for more details at this link.

Good luck.

magadan commented 2 years ago

Hello, ok, i compiled with settings:

Settings

----------------------------------------------------------------------------------------------------------------------

set(INSTALL_AS_ROOT ON CACHE BOOL "Install as root") set(USE_SYSTEMD ON CACHE BOOL "Use systemd") set(WITH_AUTHORIZATION OFF CACHE BOOL "Build with authorization") set(WITH_POSTGRESQL OFF CACHE BOOL "Build with PostgreSQL") set(WITH_SSL OFF CACHE BOOL "Build with SSL") set(WITH_CURL OFF CACHE BOOL "Build with cURL") set(WITH_SQLITE3 OFF CACHE BOOL "Build with Sqlite3")

----------------------------------------------------------------------------------------------------------------------

Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. hello HTTP/1.1 400 Bad Request Server: cs/1.0.566a0d4-b2 Date: Sun, 19 Jun 2022 03:37:00 GMT Accept-Ranges: bytes Content-Type: text/html Content-Length: 160 Connection: close

Bad Request

400 Bad Request


OCPP Central System

Connection closed by foreign host.

ufocomp commented 2 years ago

Hello!

Yes, thanks, the wrong path to the web-shell was specified in the default settings. Corrected.

You can manually specify the correct path to the web-shell by editing the /etc/cs/sites/default.json file

The correct path to the Web Shell:

{
  "hosts": ["localhost:9220"],
  "root": "www/web"
}

Or, if you need Swagger UI API:

{
  "hosts": ["localhost:9220"],
  "root": "www/docs"
}

Don't forget to disable authorization in the web shell settings by editing the /etc/cs/www/web/config.js file:

var appConfig = {
confAuthorize: false
}

Also, in the default settings, disabled process: "Сharging point emulator". You can enable it in the application settings file /etc/cs/cs.conf

[main]

## Process: Charging point emulator
[process/ChargePoint]
## default: false
enable=true
After changing the settings, the application must be restarted.

Good luck.