Webcam fails to stream in Google Chrome - IPv6/IPv4 issue

This is an informational post, which might help someone who runs into this issue.

I was having a problem whereby the webcam stream would not work on the Octoprint web page, but would work if accessed by the same URL directly from a Chrome browser.
For reference, the problem did not exist when using Firefox - everything worked fine.

I narrowed down the problem to me using both IPv4 and IPv6, and the fact that I run my own DNS server on my wired LAN segment (which is what the Octoprint server is connected to). Thus:

$ nslookup pigui
Server:		2001:8b0:fb5e::31
Address:	2001:8b0:fb5e::31#53

Name:	pigui.pickworth.me.uk
Address: 192.168.1.40
Name:	pigui.pickworth.me.uk
Address: 2001:8b0:fb5e::40

The issue arose when I use this URL to access web site:
http://pigui:5000
and the IPv4 address in the Octoprint webcam setting thus:
http://192.168.1.40:8081?action=stream

Looking in the Chrome console log when running test on the webcam link, I got CORS security errors, and Connection Denied.

From what I can see, this is caused by the Chrome DNS lookup on the server name (pigui) returning its IPv6 address (because Chrome is set to look for IPv6 first), and then seeing the IPv4 address of the webcam stream as a different, untrusted, network.

There are two solutions / workarounds that I found:

  1. Use Firefox, it "just works"(TM). However, it is possible that at some point in the future it could start doing what Chrome does.
  2. Explicitly use IPv4 addresses for both the Octoprint website and the webcam stream, so http://192.168.1.40 works in my case

I have not tried using the IPv6 address for the webcam stream, mainly because I need to access it from my wireless LAN, which is on a different, IPv4 only, sub net (ironically provided by Google hardware :slight_smile: ).

1 Like

Hello @Ian_Pickworth !

I moved it to the guides

Thanks. Sorry for posting in the wrong place :frowning:

1 Like

I know this thread is 4 years old, but it actually helped me troubleshoot a similar problem.

I don't have any custom DNS or LAN setup, but I'm seeing the same behavior where Chrome won't display my webcam stream when accessing via octopi.local, but it works perfectly fine when I use the actual IPv4 address.

Not sure if this is because I just updated to OctoPrint 1.11.4, but that's the only change I'm aware of between yesterday (when everything pretty-much worked) and today (after the update, can't see cam).

Current situation:

  • Webcam stream (some Logitech USB cam) will not display in Chrome when accessing via octopi.local
  • Stream does display in Chrome when using the full IP address
  • Stream works fine in Obico and OctoApp (i'm not sure right now where they get their URL), and Opera (using .local)

This makes me think it might be Chrome-specific, but based on the post here it seems related to IPv6/IPv4 handling.

I'm on an M1 MacBook with no special network configuration.

Temporary workarounds that work for me:

  • Use the IP address instead of octopi.local in Chrome
  • Use a different browser (Opera works fine with .local)

Posting here in case it helps with SEO and others run into this after updating. Is there a better place I should report this, like a GitHub issue or a newer thread?