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

Mock client sends invalid JSON POST request to ambi backend for sensor readings #1

Closed
wumbabum opened this issue Feb 4, 2022 · 4 comments · Fixed by #2
Closed

Mock client sends invalid JSON POST request to ambi backend for sensor readings #1

wumbabum opened this issue Feb 4, 2022 · 4 comments · Fixed by #2
Assignees

Comments

@wumbabum
Copy link
Collaborator

wumbabum commented Feb 4, 2022

Ambi backend interprets JSON here

Currently, the mock client sends an invalid JSON request, which ambi receives and is unable to parse.
This results in an empty parameters field on the backend.

See this issue for an example of the ambi response

@bortyr
Copy link
Collaborator

bortyr commented Feb 6, 2022

This is what I got from tcpdump and displaying it in wireshark
image

@jhodapp
Copy link
Contributor

jhodapp commented Feb 6, 2022

One note, temperature is spelled "tempurature" which is not correct.

@jhodapp
Copy link
Contributor

jhodapp commented Feb 6, 2022

Ah I think I know what the issue is, Wireshark doesn't see the JSON as JSON, nor will the Phoenix server because we're not passing the content-type in the HTTP header like I do in the full hardware client, e.g.: https://github.com/Jim-Hodapp-Coaching/ambi_client_cpp/blob/7aac57aa8a82d1a29085f185eed6b34582322c79/src/http_client.cpp#L132

@bortyr @calebbourg

@bortyr
Copy link
Collaborator

bortyr commented Feb 6, 2022

Yes, that's what I thought. I saw an example on stackoverflow (can't link it because SO is offline for maintenance) where somebody suggested using .json() method and sets the header accordingly to this. Though when I tried to do it quickly, lsp told me that .json method doesn't exist so maybe I missed something and simply setting .header(json/application (or sth like that)) should suffice

@jhodapp jhodapp linked a pull request Feb 7, 2022 that will close this issue
@jhodapp jhodapp closed this as completed in #2 Feb 7, 2022
jhodapp pushed a commit that referenced this issue Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants