Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
samuellavoie90 opened this issue Apr 11, 2024 · 4 comments
Closed

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

samuellavoie90 opened this issue Apr 11, 2024 · 4 comments

Comments

@samuellavoie90
Copy link

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 '/'

@matth-x
Copy link
Owner

matth-x commented Apr 13, 2024

Hi @samuellavoie90, thanks for this report!

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

@samuellavoie90
Copy link
Author

samuellavoie90 commented Apr 15, 2024

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.

@matth-x
Copy link
Owner

matth-x commented Apr 18, 2024

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 😅

@matth-x
Copy link
Owner

matth-x commented Apr 21, 2024

@samuellavoie90 The fix is ready now: #283

Can you check if it works with your WS server?

matth-x added a commit that referenced this issue May 18, 2024
* use WS path instead of URL (#278)

* update arduinoWebSockets integration
@matth-x matth-x closed this as completed May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants