dallmann-consulting / OCPP.Core

OCPP server and management UI written in .NET-Core
GNU General Public License v3.0
223 stars 91 forks source link

SQLite Error 14: 'unable to open database file'. #4

Closed tianmu88888 closed 3 years ago

tianmu88888 commented 3 years ago

Hi, I have been download from here and try to build this. But the Web page told me that "SQLite Error 14: 'unable to open database file' "

I'm using sqlite so I done this change:

"ConnectionStrings": { "SQLite": "Filename=.\..\SQLite\OCPP.Core.sqlite;" //"SqlServer": "Server=.;Database=OCPP.Core;Trusted_Connection=True;" }, and rename the sql file from OCPP.Core.Empty.sqlite to OCPP.Core.sqlite

But I still get the error? is there anything I did wrong?

Thanks!

dallmann-consulting commented 3 years ago

My first guess: you need to escape the backslashes in the path with an extra backslash:

"SQLite": "Filename=.\\..\\SQLite\\OCPP.Core.sqlite;"

If that doesn't help try an absolute path instead of a relative path. If you're running in IIS you also need to make sure that the App-Pool account has permissions on the file. Also be aware that both projects (Server and Web-UI) need access to the database (see both config files).

tianmu88888 commented 3 years ago

I use all of the default setting except the SQLite. I change the path first and then run it with "Build with SDK" this part. then copy the wwwroot to all the the folder. I did it twice from the start, but get the same error. Can I give you more things to get more help?

dallmann-consulting commented 3 years ago

Please try an absolute file path (like c:\...myPath...\SQLite\OCPP.Core.sqlite). The error message says that the database file can not be found or opened. So it can be a wrong path or an access denied problem. If you need more help I need more information about your configuration (exact file paths, IIS or Kestrel [simply start the exe files]).

tianmu88888 commented 3 years ago

Hi, I try the absolute path to fix this,But still wrong And I upload the file I use and the file path for you. https://drive.google.com/drive/folders/1du9Ed9nW_1xVfnxSAuqfSTn7k-Mi4Lb1?usp=sharing Here is the link , Sorry for your inconvenient

dallmann-consulting commented 3 years ago

If I'm not mistaken your build output is somewhere else. The ZIP file only contains the binary of the database project. I can't help you with these files. Please send exakt screenshots of:

tianmu88888 commented 3 years ago

Sorry I upload the wrong file , Because I'm trying to use the SQL Server at the same time, I have been update the file in the same url

  1. image image Here is the path picture.

  2. I keep a empty sqlite because if I make some mistake I can restart it.
  3. image image image Here is the SQLite path and the appsetting.json Thanks for your help

dallmann-consulting commented 3 years ago

I think I found it. SQLite is a file based database (like Microsoft Access). You have configured the directory path but you need to point to the ".sqlite" file. Both ".sql" files are just SQL scripts for creating a new database or migrating from a previous version. You don't need them if you start with the empty sqlite file.

dallmann-consulting commented 3 years ago

Is it working?

tianmu88888 commented 3 years ago

That works! Thanks! But I have another question , how can I connect to the real charger?

dallmann-consulting commented 3 years ago

That's a question to the manufacturer of your charger. The charger connects to the OCPP server and needs to be configured - it's the same with a simulator. The server is passive and just waits for connection request.

tianmu88888 commented 3 years ago

Yes Our Charger is support with OCPP so I just enter the same setting in the simulator to the charger and then it can works? And I don't know why my simulator only can connect at the first time and can't send meter value to the server and show: Data exchange failed - JSON is not accepted!

dallmann-consulting commented 3 years ago

Yes - basically it's the same with the charger. In some models you need to fill seperate fields (Server/IP, ID etc.) and in some you enter more or less the URL like in the simulator. You need to read the documentation of your charger. It can complicated because often the chargers don't have a Web-UI and you need to configure it with files on an USB stick.

What do you mean with "can only connect at the first time"? With the OCPP "J" protocol the chargers are always connected. They have a constant web socket connection. When the JSON is not accepted it might be a bug in the simulator or the OCPP server. Can you exactly describe what you are doing? Like: 1. Connect; 2: Start transaction; 3. ...

tianmu88888 commented 3 years ago

Thanks I'll try my own charger.

It's my description failed , I mean only my first charge point can be use,but that's fine And the ERROR message is from the step: Connect→Start Transaction→Type 20 in the meter value→Send meter Values→error

Can the fail made by the timezone? I'm in UTC+8 and the charger time display the minus value like this: image

dallmann-consulting commented 3 years ago

What simulator are you using? The ones I modified and added to the OCPP.Core project? I fixed the base simulators in respect to the time as well. The OCPP specification recommands using UTC time. I'm UTC+1/+2 (depending on summer/winter time and it works. This effect can happen when the charger/simulator start the transaction with a local timestamp (in your case UTC+8h). When the Web-UI calculates the duration it uses UTC. Then the duration is negative.

dallmann-consulting commented 3 years ago

Hold on - I get the same problem (JSON is not accepted). There seems to be a problem with the timestamps.

That's weird: I can see in my old log files that it was working 26th of April. I haven't changed anything since then. And now reading the Timestamps throws errors.

tianmu88888 commented 3 years ago

Yes I think there is some problem to these simulator. I am using the one you recommend,OCPP1.6 Simple Chargebox Simulator So I might be wrong in these days?

dallmann-consulting commented 3 years ago

I found and fixed it. It was a problem with the simulators. The hours in the timestamp were not always two digits (like "8" instead of "08"). I'm ususally working in the evening hours on the project - so I didn't notice the problem. Thank you for living so far away :-)

Get the updated simulators: https://github.com/dallmann-consulting/OCPP.Core/tree/main/Simulators