{"record":{"id":"49a6dde2cccf81d2","repo":"nautechsystems/nautilus_trader","slug":"vnc-port-must-be-between-5900-and-5999","errorCode":null,"errorMessage":"VNC port must be between 5900 and 5999","messagePattern":"VNC port must be between 5900 and 5999","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/config.rs","lineNumber":370,"sourceCode":"\n    /// Validate configuration.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if validation fails.\n    pub fn validate(&self) -> anyhow::Result<()> {\n        if self.timeout == 0 {\n            anyhow::bail!(\"Timeout must be greater than 0\");\n        }\n\n        if self.timeout > 3600 {\n            anyhow::bail!(\"Timeout must be less than 3600 seconds\");\n        }\n\n        if let Some(port) = self.vnc_port\n            && (!(5900..=5999).contains(&port))\n        {\n            anyhow::bail!(\"VNC port must be between 5900 and 5999\");\n        }\n\n        Ok(())\n    }\n}\n\nimpl Default for DockerizedIBGatewayConfig {\n    fn default() -> Self {\n        Self::builder()\n            .maybe_username(std::env::var(\"TWS_USERNAME\").ok().map(SecretString::from))\n            .maybe_password(std::env::var(\"TWS_PASSWORD\").ok().map(SecretString::from))\n            .build()\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/config.rs#L352-L388","documentation":"Config validation in the InteractiveBrokers client configuration: the optional vnc_port falls outside the standard VNC port range 5900-5999, so the config is rejected as it cannot reference a real VNC listener.","triggerScenarios":"Calling validate() with Some(port) where port < 5900 or > 5999 — e.g. supplying the display number (0, 1, :0) instead of the port, or an HTTP gateway port (4001/4002).","commonSituations":"Confusing the VNC display number with the port; copying the gateway port into vnc_port; typos like 59000 vs 5900.","solutions":["Set vnc_port to a value in 5900..=5999 (e.g. 5900)","If you have a display number N, use port 5900 + N","Leave vnc_port as None if VNC is not needed"],"exampleFix":"// before\nlet config = IbAccountConfig { vnc_port: Some(4001), ..base }; // gateway port\n// after\nlet config = IbAccountConfig { vnc_port: Some(5900), ..base };","handlingStrategy":"validation","validationCode":"if let Some(p) = config.vnc_port { assert!((5900..=5999).contains(&p), \"VNC port must be 5900..=5999\"); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = config.validate() {\n    if e.to_string().contains(\"VNC port\") {\n        eprintln!(\"{} is not a VNC port; use 5900 + display number\", config.vnc_port.unwrap_or(0));\n    }\n    anyhow::bail!(e);\n}","preventionTips":["Convert VNC display number N to port 5900 + N","Leave vnc_port unset when VNC is not used","Never reuse gateway (4001/4002) or HTTP ports for vnc_port"],"tags":["rust","config","validation","vnc","interactive-brokers"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}