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