I've been following the Server v3 installation guide and think I've found a couple issues:
- On line 29 of ovms_server.conf.default, the variable is called apikey, but PushGCM.pm is looking for api_key_file; I think this needs to be updated in the default config file
- There's a typo in the SSL section of the guide: for the CA instructions, command chmod 0600 conf/vms_server.pem should be chmod 0600 conf/ovms_server.pem
I've been having some trouble setting up the server as well. I've been trying to use the TLS authentication on port 6870 by setting up a self-signed certificate and checking off the TLS checkbox in the car's web server, but the server is giving me the following error upon connection:
tlsv1 alert unknown ca
and the car is giving me this one:
E (115144767) mongoose: mg_ssl_if_mbed_err 0x3f8bdcd0 SSL error: -9984
My read on this is that the car is trying to connect to the server, but because it's using a self-signed certificate the car won't connect because it doesn't recognize the CA. If that's the case, how do I allow my car to recognize the server's CA to allow a TLS connection? I might try Let's Encrypt as well, but I was curious what I might be doing wrong.
I was able to add my server's CA to the car module with this guide, so it is now making a connection to my server. However, after it connects, I'm now getting the following set of errors on the server:
2024-06-02 20:51:30.722645 -0700 info OVMS::Server::ApiV2: #10 - - new TLS connection from 24.114.36.165:52814
2024-06-02 20:51:30.727216 -0700 info OVMS::Server::Core: #10 - - ConnStart
Use of uninitialized value $owner in concatenation (.) or string at plugins/system/OVMS/Server/ApiV2.pm line 211.
Use of uninitialized value $owner in concatenation (.) or string at plugins/system/OVMS/Server/ApiV2.pm line 740.
Use of uninitialized value $owner in concatenation (.) or string at plugins/system/OVMS/Server/ApiV2.pm line 164.
2024-06-02 20:52:03.941951 -0700 error OVMS::Server::ApiV2: #10 - /- timeout due to no initial welcome exchange
2024-06-02 20:52:03.942507 -0700 info OVMS::Server::Core: #10 - - ConnFinish
Looking into this a bit further, it seems like none of the values are being sent ($owner, $clienttype, or $vehicleid). Clearly my car's module has some ability to connect to my server, but it isn't sending any other data along with the connection. I've filled out all of the data on the OVMS web server for the Server v3; what else could I be missing?
The issue seems to be on the server side. How are you handling authentication, and can you provide a link (or the code) to the authentication module you are using?
I was hoping to use the default Drupal authentication, but clearly I don't have it set up correctly. I set up Drupal using this guide and used MySQL rather than mariaDB and used the same Drupal username and password that I intended to use for my OVMS owner; that way I could just copy the hashed password from the Drupal database and paste it into the ovms_owners table. Based on the error code above, I'm guessing that AuthDrupal.pm is looking for table $user in the openvehicles database rather than in the drupal database.
I also copied openvehicles.info and openvehicles.module into my Drupal site at /var/www/html/drupal/sites/all/modules. When I open the Drupal webpage, I see "Open Vehicles" show up in the Modules tab, but once I enable it I don't really see anything happen?
Most likely version of drupal, etc. Probably far too complex for what you need - unless you are trying to host a server for many users to use?
If it is just for yourself, you can use AuthNone as an example. You just need to implement that one Authenticate function. Something like this:
No, at most two people would be using this for one car, maybe a second in the future; not a huge deal if we share logins. I'll probably just get rid of Drupal in that case.
I've made a copy of AuthNone.pm called AuthBasic.pm and changed the authenticate function as you suggested, replacing 'myuser' and 'mypassword' with the same one in my ovms_owners table and on the car's web interface. I changed the ovms_server.conf file to use the new plugin, but I'm still running into the same issue:
Note that I added some debug outputs to ApiV2.pm and Core.pm to see some more detail on the connection information. It shows that both $vehicleid and $clienttype are set to '-' since they're blank and $owner isn't initialized because there's no line setting it to '-' when it's blank.
In the shell on the car side, I see the following:
Where "Vehicle ID" is the same as the one in table ovms_cars and "User" is the same as the one I used in my authenticate function and in ovms_owners. Further, for simplicity I'm using the same authentication password as I am using for the car password in the ovms_cars table and the owner password in the ovms_owners table.
Hoping this is all clear, I'm very tired today so I wouldn't be surprised if some of this wasn't coherent. TL;DR: I'm getting the same error where none of the $vehicleid, $owner, or $clienttype are getting set when the car connects to the server.
Have you setup the owners and cars in the database itself? Please provide the output here:
If you are concerned about privacy posting here, you can instead email to mark (at) openvehicles (dot) com.
Note that the 'owner' field is the relationship link between ovms_cars and ovms_owners. An example of what it should look like is:
I've sent the output of those table entries to the email you specified. I think it looks okay, but let me know if anything looks incorrect. I did notice initially that my owner status was set to 0, but I've since changed that to 1 and I'm still seeing the same behaviour.
Just wanted to check in and see if you had an opportunity to check the database file I sent.
The two tables look correct.
Not sure how to debug/support this from the forums here.The issue could be any of a number, and it would require stepping through the connection, checking each stage.
Knowing that the data in the tables looks correct is a good start, thank you. I'll try to do some more debugging on my end and see if I can make any progress.
I finally got around to setting up the development environment for the vehicle module over the past week or so, which means I'm now able to add lines to the vehicle files to try and debug this further. I wanted to add a line to ovms_server_v3.cpp to where the code goes after successfully connecting to the server. I added a line before the end of the MG_EV_CONNECT case to make sure I'm getting to the handshake function, and I added another couple lines to mongoose.c to see what's happening when the handshake is called. What I'm finding is that I make it to the line where the handshake function is called (mg_send_mqtt_handshake_opt(nc, MyOvmsServerV3->m_vehicleid.c_str(), opts);), but nothing seems to be happening in the function inside mongoose.c.
What is expected to happen here? I was assuming that when mg_send_mqtt_handshake_opt is called within ovms_server_v3.cpp it would run the function in mongoose.c to actually send the handshake data to the server.
I'm confused what you are trying to do here. You are in the server v3 forum (which is about MQTT protocol), but your early messages are discussing protocol v2 (aka server v2). The v3 protocol is mqtt and completely different.
To start with, what are you trying to achieve? Are you trying to use the standard production (v2) protocol, or mqtt?
Sorry, my problem is that my personal v3 server (MQTT) isn't receiving the initial welcome message from the car (i.e. I'm getting the error "error OVMS::Server::ApiV2: #10 - /- timeout due to no initial welcome exchange). I'm not sure where in my previous messages I indicated that I was using the V2 server, but I might be misunderstanding something. I was following this guide to install the v3 server.
In any case, to debug this further I wanted to be able to compile firmware for the OVMS module itself so that I could add in my own messages and verify that the module is sending the messages correctly to my v3 server. I've cloned the OVMS v3.3.003 repo to my computer and have been compiling that with the recommended ESP-IDF v3.3.x. Now I'm just trying to go through ovms_server_v3..cpp and mongoose.c to better understand how the MQTT messages are constructed and sent to the V3 server.
The error message you provide (error OVMS::Server::ApiV2:) is from the V2 api server. Not MQTT. That is what is confusing me.
OVMS project currently has three server options:
Old code base (from historical tags)
Latest server code in v3 directory
The error message you provided (error OVMS::Server::ApiV2: #10 - /- timeout due to no initial welcome exchange) is from https://github.com/openvehicles/Open-Vehicle-Server.git v3/server/plugins/system/OVMS/Server/ApiV2.pm and is the API v2 server. That is *not* MQTT and should use the matching api v2 protocol client from OVMS.
I guess you are getting confused between version 3 of the api v2 OVMS server, versus api v3 of OVMS (standard MQTT). If you want to use API v3 (usually because of home automation integration, etc), be aware it is experimental and doesn't support any mobile App functionality at present.
Thank you Mark, I did indeed mix up the API and server versions. When I fill out the server V2 information on the module's Web UI, the car now connects to my server and the database tables gets data. I've now got both the car, server, and app talking, awesome!
One last question: for the server-> app connection, is it locked to the default non-TLS port (6867), or can you specify your own port and use TLS? I tried the format "mydomain.com:port", but that didn't seem to work for either the SSL or non-SSL port.