Web Socket issue exposing OctoPrint using cloudflared (formerly argo)

I was trying to expose my OctoPrint server through Cloudflare using cloudflared, which works similar to ngrok but offers quite a bit of additional functionality. I use it for several other apps I host off my home network and figured it would be pretty simple, but for some reason the WebSocket connection seems to fail without much useful information (likely by something in cloudflare). I've read through the Cloudflare documentation on WebSockets and tried tweaking a few

WebSocket connection to 'wss://octopi.example.com/sockjs/039/3myxvhxc/websocket' failed:   packed_libs.js?1fe9f29c:1238 

I don't see any errors in the octoprint.log.

Anyone have any thoughts of what could be causing this failure?

I guess there might be something incompatible with Cloudflared. It is very hard to work out what is going on there. Does cloudflared have any of it's own logs? Is that error message in the browser console? It seems like after failed: it should have some kind of reason - or at least, that would make it useful

I didn't try the websocket way.

But if you always connect via a PC, you can use the ssh tunnel do a port forwarding via ssh to the local 80 or 8080 or something like this.
From the phone, might be more complicated.

This reply was going to be asking if you managed to find a solution, but in my final checks I solved it.

I noticed after setting the log level of tornado to DEBUG (it's in the Octoprint logging settings), and then checking octoprint.log, that I was getting

tornado.general - DEBUG - Cross origin websockets not allowed

(Unrelated to Octoprint, I had to add a add-cors-header worker in Cloudflare in order to get status indicators on my Homer dashboard to work)

I found that in the octoprint settings, under API, checking this box solves this issue.

Allow Cross Origin Resource Sharing (CORS)

You do get a warning in Octoprint that you should be careful exposing your printer to the internet. I think I'm comfortable since I have a strong password, it's HTTPS, and I have some security features enabled in Cloudflare. Though I ought to have some 2FA enabled somehow.

1 Like

I was able to get a tunnel working with a basic install, and able to control the system with Octoremote. I made a post earlier today about it. The only issue I have is not being able to view the webcam. Were you able to get the webcam viewable through the tunnel?