matth-x / MicroOcpp

OCPP 1.6 client for microcontrollers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in void mocpp_initialize(const char *backendUrl,...

samuellavoie90 opened this issue · comments

In mocpp_initialize(const char *backendUrl,... a websocket is initialized:

webSocket->begin(host.c_str(), port, url.c_str(), "ocpp1.6");

The entire url (ws://Server.local:8500/ocpp/ChargerId) is passed to this websocket, when this library (arduinoWebSockets) was actually expecting only to have the path (/ocpp/ChargerId) passed there, this results in a badly formed HTTP packet for the initial websocket creation handshake.

image
In the screenshot you can sort of see the intended use is for URL to only have the Path component, since the default value is '/'

Hi @samuellavoie90, thanks for this report!

Did you already try to change the url parameter of webSocket->begin() accordingly? Did it work?

Yes, I already did the change: I added a new string called 'Path' under Host_Port_Path, and I concatenated the chargerID to it instead of Url. It worked well, but we only tried the non encrypted socket->begin. Before making the change, I also looked at pretty much the entire code path of socket->begin and it really does expect only the path component of the URL (first '/' included). I suspect the error was introduced when the signature for the mocpp_initialize was changed.

Thanks for taking a deeper look, will fix it like suggested.

Actually this confused me for years. It is possible to send the full URL in HTTP requests, but it's really uncommon and quite a few WS servers had issues with it. I thought the WS lib had a weird behavior there, but it turns out it was just me 😅

@samuellavoie90 The fix is ready now: #283

Can you check if it works with your WS server?