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

Assertion Error on Pico W (RP2040) #6

Open
AngryChihuahua04 opened this issue Oct 25, 2022 · 6 comments
Open

Assertion Error on Pico W (RP2040) #6

AngryChihuahua04 opened this issue Oct 25, 2022 · 6 comments

Comments

@AngryChihuahua04
Copy link

Hi there!

Was testing this library with the new Pico W, but I keep getting an error: "AssertionError: b'HTTP/1.1 400 BAD REQUEST'". It looks like the Micropython library had this issue and was fixed and I was wondering if there was a fix for this CircuitPython library?

Any and all help is appreciated!

@AngryChihuahua04 AngryChihuahua04 changed the title Assertion Error Assertion Error on Pico W (RP2040) Oct 25, 2022
@vniehues
Copy link

@AngryChihuahua04 did you ever find a solution to this? Im currently stuck with the same problem

@Neradoc
Copy link
Owner

Neradoc commented Feb 24, 2023

That means the server gave a 400 bad request response.
You can use this in your code to activate the logging of the server's response but that probably doesn't contain more info:

import adafruit_logging as logging
LOGGER = logging.getLogger("websockets.client")
LOGGER.setLevel(logging.DEBUG)

It would be interesting to know what server it is, if it's publicly accessible that would help me test it. If it's a server you are running, you could try to get some debug information on why it's not happy.

It might not like the Origin header, or there's something else. I noticed that it does not give the proper scheme: it always uses http://<host>:<port> even over https, that might be the cause.
This would be this line:

send_header(b'Origin: http://%s:%s', uri.hostname, uri.port)

@vniehues
Copy link

@Neradoc Thanks for your fast response!

the server expected a connection on wss and port 8002 but I was trying to connect with ws on 8001.
the problem is that the "server" is actually a Samsung TV and when I try to connect with wss, I get the error that the certificate is invalid. Duh. Its self signed on a local device, I get that but is there any way to "look past" the certificate with your implementation?

Thanks in advance :)

@vniehues
Copy link

Btw, connecting to the TV with Postman using WSS works. It seems to just ignore the invalid certificate, I get no warning

@Neradoc
Copy link
Owner

Neradoc commented Feb 24, 2023

Can you paste here the full error ? (The whole stacktrace with the lines and files and stuff).
I'll have to look into it, I'm not sure of what is supported in the picow implementation currently.

@vniehues
Copy link

vniehues commented Feb 25, 2023

x509-crt-bundle:Failed to verify certificate
OSError: (-12288, 'MBEDTLS_ERR_X509_FATAL_ERROR')

this is all I have unfortunately.. but as I said, I think that's not really a bug but more a feature.
the certificate on the server is bad. but for my project I need to ignore the bad certificate but I didn't find a way to disable the cert check

edit: using micropython instead I can use a very basic implementation that seems to work ok. I'd rather use CircuitPython tho. This is the working implementation

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

3 participants