-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add WebSocket at /cp/serial/ #6584
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parts I understand seem OK, but I can't really comment on the websocket implementation. Probably fine to merge when green :)
I had to comment out the ESP_LOGE error messages in websocket.c (maybe missing esp-idf include?) but then the PR compiled and I was able to reach the serial WebSocket. The Ctrl-D, Ctrl-C and return worked but I wasn't able to send normal text/commands. If I connected via USB I could enter normally and the WebSocket screen correctly mirrored what was going on in the USB console. |
@RetiredWizard Was this with Chrome? I've been mostly testing with Firefox. |
Yes, with chrome. I didn't get as much time to play with it as I had hoped, got bogged down with other board issues :/ I think I was missing some error messages by commenting out the ESP_LOGE statements but it also seemed I was able to break the socket connection by spewing a lot of output to the REPL |
I rebuilt the PR with today's main branch and replaced the ESP_LOGE statements in websocket.c with mp_printf statements. When I throw a lot of output at the serial port the websocket disconnects (stops mirroring and the SEND and CTRL buttons go grey). Nothing shows up on the DEBUG console but on the USB console the following message shows up at the point the socket disconnects:
This is one of the ESP_LOGE messages I replaced in order to get the PR to compile. Refreshing the WebSocket page reconnects it without issue. |
I changed the |
I seem to be able to reproduce this by running a uPyBasic program, the wifi connection crashes whether I'm using the serial WebSocket or not. uPyBasic does a LOT of flash i/o so maybe that has something to do with it.
The last four messages only appear if I have the WebSocket page up. I'm still running with the supervisor_disable_tick commented out of the flash.c module..... |
Hmm, after hanging the wifi several times from uPyBasic, I just ran the program sucessfully without losing the WebSocket, not quite repeatable.... I am getting a few Warning messages on the DEBUG console but everything seems to be running fine this time.
|
Reason 200 is WIFI_REASON_BEACON_TIMEOUT so I'm not sure it is a websocket issue. |
Looks like you might be right, I moved the microcontroller in the direction of my router and the program is running clean now |
I threw a hack into _origin_ok to compare against the DHCP host name in addition to the mDNS host name. It's not real pretty but it seems to get the job done. That being said, I'm not sure this test is actually doing what we're hoping it is. I don't think it's filtering out requests from rogue or outside sources. The origin variable isn't actually the origin of the request, it's the host name used in the request query, the destination may be a better name. If an IP scanner was probing a LAN with these devices, I'm assuming the rogue requests would come through with IP addresses which we're currently not blocking. I did create a hostname called badhost in my local host file and when I try to bring up one of the secure CP pages using this host name, the bad origin message is displayed and access is blocked.
|
I've built the PR with @tannewt's chrome tweak and it works great. |
@jepler Please re-review. The two build failures are unrelated to the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I didn't see anything in the later updates that was concerning, and now it's tested by someone else too.
This gives access to the serial output from a web browser.
Progress on #6174