@@ -97,6 +97,7 @@ void mocpp_initialize(const char *backendUrl, const char *chargeBoxId, const cha
9797 // parse host, port
9898 std::string host_port_path = url.substr (url.find_first_of (" ://" ) + strlen (" ://" ));
9999 std::string host_port = host_port_path.substr (0 , host_port_path.find_first_of (' /' ));
100+ std::string path = host_port_path.substr (host_port.length ());
100101 std::string host = host_port.substr (0 , host_port.find_first_of (' :' ));
101102 if (host.empty ()) {
102103 MO_DBG_ERR (" could not parse host: %s" , url.c_str ());
@@ -123,28 +124,29 @@ void mocpp_initialize(const char *backendUrl, const char *chargeBoxId, const cha
123124 }
124125 }
125126
127+ if (path.empty ()) {
128+ path = " /" ;
129+ }
130+
126131 if ((!*chargeBoxId) == ' \0 ' ) {
127- if (url .back () != ' /' ) {
128- url += ' /' ;
132+ if (path .back () != ' /' ) {
133+ path += ' /' ;
129134 }
130135
131- url += chargeBoxId;
136+ path += chargeBoxId;
132137 }
133138
134- MO_DBG_INFO (" connecting to %s -- (host: %s, port: %u)" , url.c_str (), host.c_str (), port);
139+ MO_DBG_INFO (" connecting to %s -- (host: %s, port: %u, path: %s )" , url.c_str (), host.c_str (), port, path. c_str () );
135140
136141 if (!webSocket)
137142 webSocket = new WebSocketsClient ();
138143
139- if (isTLS)
140- {
141- // server address, port, URL and TLS certificate
142- webSocket->beginSslWithCA (host.c_str (), port, url.c_str (), CA_cert, " ocpp1.6" );
143- }
144- else
145- {
146- // server address, port, URL
147- webSocket->begin (host.c_str (), port, url.c_str (), " ocpp1.6" );
144+ if (isTLS) {
145+ // server address, port, path and TLS certificate
146+ webSocket->beginSslWithCA (host.c_str (), port, path.c_str (), CA_cert, " ocpp1.6" );
147+ } else {
148+ // server address, port, path
149+ webSocket->begin (host.c_str (), port, path.c_str (), " ocpp1.6" );
148150 }
149151
150152 // try ever 5000 again if connection has failed
0 commit comments