TFyre / bambu-farm

Bambulab Web interface for multiple printers
Apache License 2.0
173 stars 18 forks source link

Everything works but the camera #74

Closed TheCableGuy99 closed 5 months ago

TheCableGuy99 commented 6 months ago

Hi,

I've been at this all night and have tried everything I can think of. It's all working apart from the camera which depending on what options I change either gives me a blank white page or comes up saying "refused to connect".

I'm using the docker version and I have attached my config files (with sensitive data redacted), can you see anything i''m getting wrong please?

To confirm some details:

The printer is called: Bambu 1 The IP of the printer is: 192.168.10.231 (static IP) The IP of the Raspberry PI 4B is: 192.168.1.227 (static IP)

compose.yml.txt mediamtx.yml.txt reverse-proxy.conf.txt bambu-web-env.txt common-liveview.yml.txt

The logs for the containers are also attached which probably give the issue away but I'm unsure of the issue myself, I'm sure it's just a config error I'm missing Any help would be really appreciated.

bambu1-mediamtx-1_log.txt bambu1-nginx-1_log.txt bambu1-printer1-1_log.txt

Thank you!

TheCableGuy99 commented 6 months ago

JJust re-uploading one of the docker logs as it contained sensitive data.

bambu1-printer1-1_log.txt

TheCableGuy99 commented 6 months ago

One last thing.... this is what I see when I run "docker compose up". I'm sure it's probably in the logs but just in case something is included here thats not in the other logs I thought I'd include it.

Start_Up.txt

Thanks again for any help!

TheCableGuy99 commented 6 months ago

Hey, still struggling with this if anyone can help please?

TFyre commented 6 months ago

from mediamtx container:

ERR: json: cannot unmarshal string into Go struct field alias.webrtcAdditionalHosts of type []string

from the printer1 container:

[tcp @ 0x55901c3e10] Failed to resolve hostname mediamtx: Name or service not known

So issue is that printer1 video stream cannot find the mediamtx container because of config issue.

Here is the problem:

mediamtx.yml

webrtcAdditionalHosts: 192.168.1.227

This should be

webrtcAdditionalHosts: [192.168.1.227]
TheCableGuy99 commented 6 months ago

Hey @TFyre ,

Thanks for replying :)

I've changed it and rebooted but it's still showing as "Refused to connect" Screenshot 2024-04-28 200053

So I killed the containers and rebuilt them incase that config file played any part in the containers being built and it's the same.

Could there be anything else that is incorrect in my config?

I was unsure about the "PRINTER_ID" in the compose.yml and common-liveview.yml . I wasn't sure if this should be set to "myprinter1" or as device_id is in "bambu-web-env.txt"? Could you confirm what the "PRINTER_ID" should be set to in these files please? Maybe this is the issue?

TFyre commented 6 months ago
  1. Related to the screenshot / connection refused: Its not clear where you want to connect... is this browser or something else?
  2. Use common-liveview without any modifications
  3. Printer_id should match the printer id from the .env check https://github.com/TFyre/bambu-farm/tree/main/docker/bambu-liveview#adding-your-printers
TheCableGuy99 commented 6 months ago

Hey,

I'm sorry about this but I'm still confused....

1) This is the screenshot from the window in the web interface/browser where the printers camera image should be appearing 2) You say use common-liveview without any modifications? Surely I have to edit the "Fix me" parts? This is all I have changed in the version I've uploaded for you to see? Have I changed something else because I cannot see anything additional? 3) Lastly, inn the .env there is no "printer_id" which is why I'm unsure.... There is the following (credentials changed): bambu.printers.myprinter1.name=Bambu 1 bambu.printers.myprinter1.device-id=01*****29

So would I enter: 1) myprinter1 2) Bambu 1 3) 01*****29

Sorry for any confusion my heads just mashed I've been trying to get this working so long now.

Thanks!

TheCableGuy99 commented 6 months ago

Just to add, I note from the link it says: PRINTER_ID is the printer id in the .env configuration file eg:

bambu.printer.PRINTER_ID.name=My Printer Name

It's still not clear if I should be using "myprinter1" or "Bambu 1" so I tried both and it's still not working with either :(

Does it matter that the Raspberry Pi is on a different VLAN? It has full access to the printer.

TheCableGuy99 commented 6 months ago

It's not related to this. Something else is wrong. I set the following: "bambu.printer.myprinter1.name=myprinter1"

So everything should be "myprinter1", I set this in the "common-liveview.yml" and compose.yml" files and re created the docker containers and it still won't connect.

Something else is wrong :(

TFyre commented 6 months ago

You have conflicting configuration options

  1. Please change bambu-web-env.txt to this:
    
    bambu.dark-mode=true

bambu.use-bouncy-castle=true bambu.live-view-url=/_camerastream/

bambu.printers.myprinter1.name=Bambu 1 bambu.printers.myprinter1.device-id=00****38 bambu.printers.myprinter1.access-code=*** bambu.printers.myprinter1.ip=192.168.10.231 bambu.printers.myprinter1.model=x1c bambu.printers.myprinter1.stream.live-view=true

bambu.users.myusername.password=***** bambu.users.myusername.role=admin

quarkus.http.limits.max-body-size=150M


2. Since max-body-size above is 150M, also update `reverse-proxy.conf`:

client_max_body_size 150M;


3. use original `common-liveview.yml`

4. Start everything again: `docker compose up`

5. Check logs for `mediamtx` container. It should startup without issues. Confirm that it doesnt show this error:

ERR: json: cannot unmarshal string into Go struct field alias.webrtcAdditionalHosts of type []string

If it still has errors, upload the log file

6. Check logs for `printer1` container. It should startup without issues. Confirm that it doesnt show this error:

[tcp @ 0x55901c3e10] Failed to resolve hostname mediamtx: Name or service not known



7. Once this is all ready, you should be able to view the printer:
via mediamtx directly: http://192.168.1.227:8889/myprinter1
and via nginx (which is what the frontend would do): http://192.168.1.227:8080/_camerastream/myprinter1
it these dont work, let me know what breaks

8. Test via the normal frontend http://192.168.1.227:8080/
TheCableGuy99 commented 6 months ago

Hey,

I think we are getting somewhere.... http://192.168.1.227:8889/myprinter1 <<< this works

http://192.168.1.227:8080/_camerastream/myprinter1 <<< this says "Could not navigate to 'myprinter1' " http://192.168.1.227:8080/ << same error as above, I presume it's the same stream just in a window.

1) I changed bambu-web-env.txt to include just what you said and removed everything else. 2) I already changed reverse-proxy.conf to 150M also (thank you) 3) I am still unclear about this. You keep just saying "use original common-liveview.yml", but as said before the original is the same as the one I've been using apart from the parts that says "FIX ME". So I am unsure if you want me to leave this as "FIX ME" or change them. I have tried with it as nothing changed and with them changed and it doesn't work either way. Please can you confirm if I should be changing the parts that says "FIX ME" and if so what "PRINTER_ID" should be? "myprinter1" or, the printers serial number? 4) Deleted and rebuilt 5) Logs attached, doesn't show what you said to look for 6) Logs attached, doesn't show what you said to look for

nginx.txt mediamtx.txt bambuweb.txt

Thanks for all your help :)

TheCableGuy99 commented 6 months ago

Re-uploading myprinter1.log as I didn't remove personal info: myprinter1.txt

TFyre commented 6 months ago
  1. Leave everything with fixme's as is... its a template and gets replaced with the compose.yml

A. http://192.168.1.227:8889/myprinter1 B. http://192.168.1.227:8080/_camerastream/myprinter1

If A works and B doesnt it means something in nginx is wrong... please make sure you are using the default reverse-proxy.conf with only 1 modification for the body length

All other config is correct at this time 😄

As soon as the nginx stuff is sorted frontend will work too

TheCableGuy99 commented 6 months ago

Hey,

Okay thanks for clarifying point "3", i've left it completely as default.

I've re-copied reverse-proxy.conf and just changed the upload to 150m.

Deleted all containers and re-composed. It is the same but I have a theory I will get to, I just want to point out the facts first.... http://192.168.1.227:8889/myprinter1 << still works http://192.168.1.227:8080/_camerastream/myprinter1 <<< still says "Could not navigate to 'myprinter1' "

When "docker compose up" I see only the following errors from different containers: printer1-1 | [rtsp @ 0x55b8a3a3d0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly printer1-1 | [vost#0:0/copy @ 0x55b8a3d660] Non-monotonic DTS; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.

bambuweb-1 | 2024-04-29 19:38:57,279 ERROR [com.tfy.bam.ssl.NoopTrustSocketFactory] (main) Using INSECURE com.tfyre.bambu.ssl.NoopTrustSocketFactory

bambuweb-1 | 2024-04-29 19:39:00,608 INFO [com.tfy.bam.pri.BambuPrintersImpl] (executor-thread-1) Bambu 1: started bambuweb-1 | 2024-04-29 19:39:01,294 INFO [com.vaa.qua.QuarkusInstantiator] (executor-thread-2) Can't find any @VaadinServiceScoped bean implementing 'I18NProvider'. Cannot use CDI beans for I18N, falling back to the default behavior.

Finally the full log from nginx as you say this is probably the cause: /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up 2024/04/29 19:38:50 [notice] 1#1: using the "epoll" event method 2024/04/29 19:38:50 [notice] 1#1: nginx/1.26.0 2024/04/29 19:38:50 [notice] 1#1: built by gcc 13.2.1 20231014 (Alpine 13.2.1_git20231014) 2024/04/29 19:38:50 [notice] 1#1: OS: Linux 6.6.28+rpt-rpi-v8 2024/04/29 19:38:50 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2024/04/29 19:38:50 [notice] 1#1: start worker processes 2024/04/29 19:38:50 [notice] 1#1: start worker process 22 2024/04/29 19:38:50 [notice] 1#1: start worker process 23 2024/04/29 19:38:50 [notice] 1#1: start worker process 24 2024/04/29 19:38:50 [notice] 1#1: start worker process 25 2024/04/29 19:38:54 [error] 22#22: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.61, server: reverse-proxy, request: "GET /VAADIN/push?v-r=push&v-uiId=1&v-pushId=9e38f105-e943-4b10-bb50-c8d95eb709cc&X-Atmosphere-tracking-id=62dbc093-dfce-472e-a876-7c9686ba0aa6&X-Atmosphere-Framework=3.1.2-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true&X-Vaadin-LastSeenServerSyncId=28 HTTP/1.1", upstream: "http://172.18.0.3:8080/VAADIN/push?v-r=push&v-uiId=1&v-pushId=9e38f105-e943-4b10-bb50-c8d95eb709cc&X-Atmosphere-tracking-id=62dbc093-dfce-472e-a876-7c9686ba0aa6&X-Atmosphere-Framework=3.1.2-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true&X-Vaadin-LastSeenServerSyncId=28", host: "192.168.1.227:8080" 2024/04/29 19:38:54 [error] 23#23: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.61, server: reverse-proxy, request: "GET /VAADIN/push?v-r=push&v-uiId=2&v-pushId=9e38f105-e943-4b10-bb50-c8d95eb709cc&X-Atmosphere-tracking-id=5ab7d7d8-a73d-4e31-9f48-6b1af98c8b3c&X-Atmosphere-Framework=3.1.2-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true&X-Vaadin-LastSeenServerSyncId=1 HTTP/1.1", upstream: "http://172.18.0.3:8080/VAADIN/push?v-r=push&v-uiId=2&v-pushId=9e38f105-e943-4b10-bb50-c8d95eb709cc&X-Atmosphere-tracking-id=5ab7d7d8-a73d-4e31-9f48-6b1af98c8b3c&X-Atmosphere-Framework=3.1.2-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true&X-Vaadin-LastSeenServerSyncId=1", host: "192.168.1.227:8080"

Now, if you don't see anything else wrong I wonder if this is a firewall issue?

I asked earlier if this could be a problem with the printer being on a different vLAN? I still suspect this might be a problem? 192.168.1.227 > full access to > 192.168.10.231 192.168.10.231 > no access to > 192.168.1.227

So if it just needs to pull a stream I see no issues, but if the printer needs to communicate back to the bambu-farm server it doesn't have access to. Please confirm if it needs to and what ports would need to be opened if so?

Thanks again :) We will get there i'm sure.

TheCableGuy99 commented 6 months ago

I also note that there are no published ports for the printer container... not sure if this should be like this or not?

Screenshot 2024-04-29 205555

TFyre commented 6 months ago

I also note that there are no published ports for the printer container... not sure if this should be like this or not?

Its perfect. The printer container doesnt serve anything. It reads video from the bambu printer and streams it into mediamtx container.

I asked earlier if this could be a problem with the printer being on a different vLAN? I still suspect this might be a problem?

Its not an issue. Bambu farm can connect to the printer without any issue and you can stream the video from mediamtx with a direct connection. The only thing thats broken is nginx reverse proxy.

Try to run curl and paste the output:

curl -v http://192.168.1.227:8080/_camerastream/myprinter1
TheCableGuy99 commented 6 months ago

While I was waiting for a reply I also moved the Pi to the same subnet/vlan on 192.168.10.210 (printer on 192.168.10.231)

Changed the IP in mediamtx.yml and deleted/re-created the containers. It was the same as you'd said.

I ran the command and it appears to connect fine (unless I'm reading it wrong?):

So yeah maybe just something in nginx not right?

TFyre commented 6 months ago

Looks like the rewrite in reverse-proxy.conf is causing some issues, please replace it with:

        rewrite ^/_camerastream/([^.]*[^/])$ /$1/ break;

If this works, I will update the template, otherwise please let me know how we can make contact directly so I can debug remotely. Discord? Telegram? Something else?

TheCableGuy99 commented 6 months ago

Hi mate,

Unfortunately, still says cannot navigate to printer1.

I'm on discord under "TheCableGuy96" but don't actively use it unless I need to go on. Maybe give me a time you want to meet and we can do a teamviewer session? Please specify timezone as I'm not sure where in the world you are, i'm in England so London time.

I'm on there now in case you are around?

Thanks :)

TFyre commented 6 months ago

Haven forgotten about this, currently traveling. Please try to do docker compose down to ensure all containers gets deleted and then docker compose up.

When Im back from holiday I will reach out via discord so we can setup a direct session 😄

TheCableGuy99 commented 6 months ago

Hey,

I was actually using portainer and deleting the containers so the same thing :/

I'm on the beer all weekend anyway so give me a shout when you are back off holiday and we can look at it then.

Have a nice time :)