Trouble making HTTP requests from docker container
-
@chrishamm Hypertext Transfer Protocol
GET http://192.168.75.110/rr_status?type=3 HTTP/1.1\r\n
[Expert Info (Chat/Sequence): GET http://192.168.75.110/rr_status?type=3 HTTP/1.1\r\n]
[GET http://192.168.75.110/rr_status?type=3 HTTP/1.1\r\n]
[Severity level: Chat]
[Group: Sequence]
Request Method: GET
Request URI: http://192.168.75.110/rr_status?type=3
Request Version: HTTP/1.1
Host: 192.168.75.110\r\n
User-Agent: curl/7.74.0\r\n
Accept: /\r\n
\r\n
[Full request URI: http://192.168.75.110/rr_status?type=3]
[HTTP request 1/1]
[Response in frame: 4903] -
@Peter-Lebiedzinski And the response:
Hypertext Transfer Protocol
HTTP/1.1 404 page not found<br>Check that the SD card is mounted and has the correct files in its /www folder\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 404 page not found<br>Check that the SD card is mounted and has the correct files in its /www folder\r\n]
[HTTP/1.1 404 page not found<br>Check that the SD card is mounted and has the correct files in its /www folder\r\n]
[Severity level: Chat]
[Group: Sequence]
Response Version: HTTP/1.1
Status Code: 404
[Status Code Description: Not Found]
Response Phrase: page not found<br>Check that the SD card is mounted and has the correct files in its /www folder
Connection: close\r\n
\r\n
[HTTP response 1/1]
[Time since request: 0.213434000 seconds]
[Request in frame: 4848]
[Request URI: http://192.168.75.110/rr_status?type=3]
File Data: 239 bytes
Data (239 bytes) -
@Peter-Lebiedzinski It doesn't sound like the Duet gets an rr_status request, I suspect something alters your request. Even if you send something like
rr_foobar
(i.e. an unknown command), you get backYour Duet rejected the HTTP request: Unknown request
and not404 page not found
.You can hook up a USB cable to your Duet, open a serial terminal, and send
M111 P2 S1
to enable debugging for the webserver which lets you track incoming requests:HTTP connection accepted Sending JSON reply, length 736 HTTP req, command words { GET /rr_status HTTP/1.1 }, parameters { type=3 }
-
@chrishamm I've also been suspecting that something is changing or re-routing the request. Perhaps something in the server configuration. Would you be able to point me to the file locations in the repository for the following (I'm not familiar with Duet):
-
File that handles the HTTP routes
-
Server configuration file (nginx.conf if Duet uses nginx)
I think this would be a good starting point for me to see what is happening in the background.
-
-
@Peter-Lebiedzinski @chrishamm Since I don't currently have access to a USB cable with duet until Sunday, and this is time-sensitive for me.
-
@Peter-Lebiedzinski Since reprapfirmware is using its own little http server there is no dedicate config file. Here you can find some docs about the general API: https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests Note that every request starting with /rr_ is covered there.
Every other request is a file request. Probably some subdirectory (like /foobar/rr_status) is added to your request leading to that error. Without further debugging as pointed out above it's hard to say what it is.
Maybe you can run Wireshark on the host and capture what exactly is going on.
-
@chrishamm It looks like the request URI is not resolving properly and this is causing the server to treat it as a file request:
https://github.com/Duet3D/RepRapFirmware/blob/v3-chrishamm/src/Networking/HttpResponder.cpp#L1140
Wireshark traces:
Working request payload:
Hypertext Transfer Protocol
GET /rr_status HTTP/1.1\r\n
Host: 192.168.75.110\r\n
User-Agent: curl/7.83.1\r\n
Accept: /\r\n
\r\n
[Full request URI: http://192.168.75.110/rr_status]
[HTTP request 1/1]
[Response in frame: 9957]Not working request payload:
Hypertext Transfer Protocol
GET http://192.168.75.110/rr_status HTTP/1.1\r\n
Host: 192.168.75.110\r\n
User-Agent: curl/7.74.0\r\n
Accept: /\r\n
\r\n
[Full request URI: http://192.168.75.110/rr_status]
[HTTP request 1/1]
[Response in frame: 23915] -
All that HTTP and Docker stuff is way out of my knowledge zone, but I'd try to "ping" the Duet bord from inside the docker container.
Maybe Duets IP address is out of Dockers reach? -
@Peter-Lebiedzinski Thanks, that explains it, looks like the Duet HTTP server didn't understand absolute URIs. I've got a fix ready, if you are comfortable running out a beta version, here my current dev build for the 6HC with that fix.
-
@chrishamm Okay I can try the new build. Will it work on the following Duet hardware:
Board: Duet 2 WiFi (2WiFi)
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.4 (2022-10-20)
Duet WiFi Server Version: 1.27 -
@Peter-Lebiedzinski Sorry, that's for the 6HC, for some reason I thought you were using that. I'll prepare another Duet 2 build when I get home again.
-
@chrishamm Great. Thank you for the fast support.
-
@Peter-Lebiedzinski Here you go.
-
@chrishamm This new firmware has fixed the issue. Thank you.
-
@chrishamm would we be able to generate the firmware for the Duet 3 6XD board as well?
-
@Peter-Lebiedzinski the fix should be included in 3.5b3
-
@chrishamm Sorry for asking again, but I am working with someone who is unable to use the latest version 3.5b3, and has to use 3.4.5, specifically with the following:
Board: Duet 3 MB6XD (MB6XD)
DSF Version: 3.4.5
Firmware: RepRapFirmware for Duet 3 MB6XD 3.4.5
Duet Web Control 3.4.5Could you generate the firmware for this configuration? If possible, in the future, I'd like to save you the trouble of generating these files, is there documentation on how I can generate these files myself?
-
@Peter-Lebiedzinski I've back-ported the fix to the 3.4-dev branch, so it will be included in the forthcoming 3.4.6 release.