Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with docker image #16

Open
mmzeynalli opened this issue Apr 22, 2024 · 9 comments
Open

Problems with docker image #16

mmzeynalli opened this issue Apr 22, 2024 · 9 comments

Comments

@mmzeynalli
Copy link

mmzeynalli commented Apr 22, 2024

Good day,
I recently wrote an OCPP application and wanted to test it with this nice simulator tool. However, when I run it in docker, I get error messages and empty web pages:

[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/simulator.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/simulator.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/ws-conn.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/ws-conn.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/bootstats.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/opstore.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/opstore.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/txstore.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/txstore.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/ocpp-config.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/ocpp-config.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/client-state.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/client-state.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/reservations.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/reservations.jsn
[MO] info (MicroOcpp.cpp:344): initialized MicroOcpp v1.1.0
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/simulator.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/simulator.jsn
[MO] ERROR (FilesystemUtils.cpp:96): Could not open file ./mo_store/simulator.jsn
[MO] ERROR (ConfigurationContainerFlash.cpp:264): could not save configs file: ./mo_store/simulator.jsn
[MO] warning (MicroOcppMongooseClient.cpp:474): Insecure connection (WS)
[MO] info (MicroOcppMongooseClient.cpp:478): connection ws://echo.websocket.events/charger-01 -- connected!
[MO] Recv: echo.websocket.events sponsored by Lob.com
[MO] warning (RequestQueue.cpp:182): Invalid input! Not a JSON
[MO] warning (MicroOcppMongooseClient.cpp:484): processing input message failed
[MO] Send: [2,"1000000","BootNotification",{"chargePointModel":"MicroOcpp Simulator","chargePointVendor":"MicroOcpp"}]
[MO] Recv: [2,"1000000","BootNotification",{"chargePointModel":"MicroOcpp Simulator","chargePointVendor":"MicroOcpp"}]
[MO] Send: [3,"1000000",{"currentTime":"2022-01-28T11:59:55.000Z","interval":86400,"status":"Accepted"}]
[MO] Recv: [3,"1000000",{"currentTime":"2022-01-28T11:59:55.000Z","interval":86400,"status":"Accepted"}]
[MO] info (BootNotification.cpp:91): request has been Accepted
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 0)
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 1)
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 2)

And there is no station/connectors in web page:

image
image

I am using MacOS 13.6

@mmzeynalli
Copy link
Author

Update:
I found out that the error was happening as mo_store folder was missing in docker, as it is given in .dockerignore file. I added RUN mkdir mo_store/ in Dockerfile, now it creates files without a problem, however, hangs when it does requests:

[MO] info (MicroOcpp.cpp:344): initialized MicroOcpp v1.1.0
[MO] debug (OperationRegistry.cpp:40): registered operation MeterValues
[MO] debug (OperationRegistry.cpp:40): registered operation ClearChargingProfile
[MO] debug (OperationRegistry.cpp:40): registered operation GetCompositeSchedule
[MO] debug (OperationRegistry.cpp:40): registered operation SetChargingProfile
[MO] debug (Model.cpp:296): supported feature profiles: Core,LocalAuthListManagement,Reservation,SmartCharging,RemoteTrigger
[MO] warning (MicroOcppMongooseClient.cpp:474): Insecure connection (WS)
[MO] info (MicroOcppMongooseClient.cpp:478): connection ws://echo.websocket.events/charger-01 -- connected!
[MO] Send: [2,"1000000","BootNotification",{"chargePointModel":"MicroOcpp Simulator","chargePointVendor":"MicroOcpp"}]
[MO] Recv: echo.websocket.events sponsored by Lob.com
[MO] warning (RequestQueue.cpp:182): Invalid input! Not a JSON
[MO] warning (MicroOcppMongooseClient.cpp:484): processing input message failed
[MO] Recv: [2,"1000000","BootNotification",{"chargePointModel":"MicroOcpp Simulator","chargePointVendor":"MicroOcpp"}]
[MO] Send: [3,"1000000",{"currentTime":"2022-01-28T11:59:55.000Z","interval":86400,"status":"Accepted"}]
[MO] Recv: [3,"1000000",{"currentTime":"2022-01-28T11:59:55.000Z","interval":86400,"status":"Accepted"}]
[MO] info (BootNotification.cpp:91): request has been Accepted
[MO] debug (Connector.cpp:429): Status changed  -> Available 
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 0)
[MO] debug (Connector.cpp:429): Status changed  -> Available 
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 1)
[MO] debug (Connector.cpp:429): Status changed  -> Available 
[MO] info (StatusNotification.cpp:53): New status: Available (connectorId 2)
[MO] info (SmartChargingService.cpp:506): New limit for connector 1, scheduled at = 2022-01-28T11:59:55.000Z, nextChange = 2037-01-01T00:00:00.000Z, limit = {-1.000000,-1.000000,-1}
[MO] Send: [2,"1000001","StatusNotification",{"connectorId":0,"errorCode":"NoError","status":"Available","timestamp":"2022-01-28T11:59:55.000Z"}]
[MO] Recv: [2,"1000001","StatusNotification",{"connectorId":0,"errorCode":"NoError","status":"Available","timestamp":"2022-01-28T11:59:55.000Z"}]
[MO] Send: [3,"1000001",{}]
[MO] Recv: [3,

Now, I cannot even open the page.

@kaisarprima
Copy link

have you solved this problem now? cause i have the same issue. Thanks

@mmzeynalli
Copy link
Author

As I had main application in port 8000, I tried to run this docker image in port 8001. However, it failed as I have shown above. When I try to run it in 8000, it works as it should. I have no idea why.

@matth-x
Copy link
Owner

matth-x commented May 1, 2024

@mmzeynalli Thanks for the report, the missing mo_store folder is definitely a problem. Does the change in #18 solve the issue?

The dashboard constantly sends HTTP requests to the main Simulator app. For that it uses URLs based on the API root which is hardcoded in the dashboard sources: https://github.com/agruenb/micro-ocpp-dashboard/blob/015a0e816ca4fc617e67acdbe7d067688d6b3939/.env.development

To change the port number, you need to build the dashboard with a custom .env manifest. Here is the relevant description:

Edit:

Also, the Simulator main app opens a listening socket for these HTTP requests on port 8000 by default. It's also necessary to change the port number here:

mg_http_listen(&mgr, "0.0.0.0:8000", http_serve, NULL); // Create listening connection

@mmzeynalli
Copy link
Author

It solves not being able to docker up, but, still I cannot connect to my websocket through this docker:

[MO] debug (MicroOcppMongooseClient.cpp:160): (re-)connect to ws://83c8-46-162-93-142.ngrok-free.app/socar-cp003
[MO] warning (MicroOcppMongooseClient.cpp:474): Insecure connection (WS)
6be66a0 1 mongoose.c:403:mg_error       194 0x8 handshake error
6be66a0 1 MicroOcppMongooseClient.cpp:4 0x8 handshake error
[MO] info (MicroOcppMongooseClient.cpp:492): connection ws://83c8-46-162-93-142.ngrok-free.app/socar-cp003 -- error
[MO] info (MicroOcppMongooseClient.cpp:492): connection ws://83c8-46-162-93-142.ngrok-free.app/socar-cp003 -- closed
[MO] debug (MicroOcppMongooseClient.cpp:123): WS unconnected
[MO] debug (MicroOcppMongooseClient.cpp:123): WS unconnected

@matth-x
Copy link
Owner

matth-x commented May 1, 2024

Can you connect to wss://echo.websocket.events/ (leave ChargeBoxId blank)?

@mmzeynalli
Copy link
Author

Yes, the default settings work just fine.

@mmzeynalli
Copy link
Author

@mmzeynalli Thanks for the report, the missing mo_store folder is definitely a problem. Does the change in #18 solve the issue?

The dashboard constantly sends HTTP requests to the main Simulator app. For that it uses URLs based on the API root which is hardcoded in the dashboard sources: https://github.com/agruenb/micro-ocpp-dashboard/blob/015a0e816ca4fc617e67acdbe7d067688d6b3939/.env.development

To change the port number, you need to build the dashboard with a custom .env manifest. Here is the relevant description:

Edit:

Also, the Simulator main app opens a listening socket for these HTTP requests on port 8000 by default. It's also necessary to change the port number here:

mg_http_listen(&mgr, "0.0.0.0:8000", http_serve, NULL); // Create listening connection

And, I believe making port number flexible, without users changing code would be better experience. I had to move my main application port in order to be able to use this tool.

@mmzeynalli
Copy link
Author

mmzeynalli commented May 1, 2024

I just tried to move MicroOcppSimulator to the same environment as my main code, creating "locality" with other containers. However, I get the same error, shown in previous comments. This is my websocket code:

    server = await websockets.serve(
        on_connect,
        '0.0.0.0',
        rabbitmq_settings.WS_SERVER_PORT,
    )

    task = asyncio.create_task(
        consume(
            rabbitmq_settings.TASK_EXCHANGE_NAME,
            on_message=lambda task: process_tasks(server, task),
        ),
    )
    background_tasks.add(task)

    await server.wait_closed()```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants