The correct way to get the port OctoPrint server is listening on?


#1

In my plugin I'm using settings.getInt(["server", "port"]) to obtain the server port. However, I found out that when OctoPrint is launched with octoprint --port=5001, the value returned from settings.getInt(["server", "port"]) is still 5000.

What's the right way to get the port OctoPrint server is actually listening on inside a plugin?


#2

I suppose @foosel would like to have your octoprint.log file.

I think I'd also wonder if you are trying to connect via IPv4 or IPv6. From my own naïve viewing of this code, it looks like it's hard-coded to 5000 but there's probably other stuff going on that's lost on me.


#3

octoprint.log files doesn't show anything since nothing is being logged.


#4

@foosel Hope you have a quick answer here?


#5

She's in Germany, btw. If she does stop in, it will be hours from now.


#6

Got it thx @OutsourcedGuru


#7

Hi!
Keep in mind: Today is National Holiday.


#8

I found the answer myself. It's actually documented here: http://docs.octoprint.org/en/master/plugins/mixins.html#octoprint.plugin.StartupPlugin.on_startup

But I wouldn't have found the document if I hadn't had traced the code all the way there. That's why software is so hard isn't it. :wink:


#9

Actually, I love open-source software. Many times people ask questions about OctoPrint or a plugin and I can just read through the code and sound authoritative, as if I actually knew what I were talking about. ha


#10

Just back from vacation, but I see you already found your answer :slight_smile: :+1: