18 posts / 0 new
Last post
Alenux
Server v3 Guide Issues

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.

Alenux
One part fixed

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?

markwj
markwj's picture
The issue seems to be on the

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?

Alenux
I was hoping to use the

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?

markwj
markwj's picture
Most likely version of drupal

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:

sub Authenticate
  {
  my ($user,$password) = @_;
  return (($user eq 'myuser')&&($password eq 'mypassword'))?'*':'';
  }

Alenux
No, at most two people would

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:

2024-06-12 01:38:07.355346 -0700 info  OVMS::Server::ApiV2: #10 - - new TLS connection from 154.43.164.63:50234
2024-06-12 01:38:07.359713 -0700 info  OVMS::Server::Core: #10 - - ConnStart
2024-06-12 01:38:07.359813 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: handle: AnyEvent::Handle=HASH(0x5866f297cd30)
2024-06-12 01:38:07.359891 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: proto: v2/6870/tls
2024-06-12 01:38:07.359966 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: host: 154.43.164.63
2024-06-12 01:38:07.360037 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: port: 50234
2024-06-12 01:38:07.360112 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: callback_tx: CODE(0x5866f1dc9050)
2024-06-12 01:38:07.360188 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: callback_shutdown: CODE(0x5866f1ddf7a8)
2024-06-12 01:38:07.360261 -0700 info  OVMS::Server::Core: #10 - - TEMPORARY DEBUG: fh: GLOB(0x5866f2a26638)
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 215.
2024-06-12 01:38:52.158459 -0700 info  OVMS::Server::ApiV2: #10 TEMPORARY DEBUG: Vehicle ID: - |  Owner:   | Client Type:  -
Use of uninitialized value $owner in concatenation (.) or string at plugins/system/OVMS/Server/ApiV2.pm line 744.
Use of uninitialized value $owner in concatenation (.) or string at plugins/system/OVMS/Server/ApiV2.pm line 164.
2024-06-12 01:38:52.158843 -0700 error OVMS::Server::ApiV2: #10 - /- timeout due to no initial welcome exchange
2024-06-12 01:38:52.159111 -0700 info  OVMS::Server::Core: #10 - - ConnFinish

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:

I (935796097) ovms-server-v3: Connection is <server_name>:<port> <Vehicle ID>/<User> topic ovms/<User>/<Vehicle ID>

I (935796097) ovms-server-v3: Status : Connecting

I (935799347) ovms-server-v3: Connection successful

I (935829467) ovms-server-v3: Status: Disconnected from OVMS Server V3

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. 

markwj
markwj's picture
Have you setup the owners and

Have you setup the owners and cars in the database itself? Please provide the output here:

  • select owner,name,status,deleted,changed from ovms_owners;
  • select vehicleid,vehiclename,owner,deleted,changed,v_lastupdate from ovms_cars;

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:

+-----------+-------------+-------+---------+---------------------+---------------------+
| vehicleid | vehiclename | owner | deleted | changed             | v_lastupdate        |
+-----------+-------------+-------+---------+---------------------+---------------------+
| TESTCAR   | TESTCAR     |     1 |       0 | 2012-10-10 14:39:27 | 2018-03-05 05:25:38 |
+-----------+-------------+-------+---------+---------------------+---------------------+

+-------+--------+--------+---------+---------------------+
| owner | name   | status | deleted | changed             |
+-------+--------+--------+---------+---------------------+
|     1 | tester |      1 |       0 | 2013-11-07 08:54:39 |
+-------+--------+--------+---------+---------------------+

Alenux
I've sent the output of those

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.

Alenux
Check in

Just wanted to check in and see if you had an opportunity to check the database file I sent.

markwj
markwj's picture
The two tables look correct.

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.

Alenux
Knowing that the data in the

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.

Alenux
More developments

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.

markwj
markwj's picture
I'm confused what you are

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?

Alenux
Sorry, my problem is that my

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.

 

markwj
markwj's picture
The error message you provide

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:

  1. https://github.com/openvehicles/Open-Vehicle-Server.git
    Old code base (from historical tags)
  2. https://github.com/openvehicles/Open-Vehicle-Server.git
    Latest server code in v3 directory
  3. Any third party MQTT server (mosquitto, etc)

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.

Alenux
Thank you Mark, I did indeed

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.

markwj
markwj's picture
One last question: for the

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.

I think the current apps don't support TLS connections. Only the standard 6867.

Alenux
Makes sense, thanks Mark!

Makes sense, thanks Mark!

Log in or register to post comments
randomness