openhab / openhab-distro

The binary distribution of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.3k stars 391 forks source link

Miele Cloud Binding on OpenHab Docker cannot authorize due to too many threads required #1596

Closed robkamp closed 1 year ago

robkamp commented 1 year ago

When trying to authenticate for the Miele Cloud binding using containerized OpenHAB (Docker) it fails with the following error in the log file.

Insufficient configured threads: required=16 < max=10 for QueuedThreadPool[OH-httpClient-OAuthConnector]

runtimeInfo:
  version: 4.1.0
  buildString: "Build #3680"
locale: nl-NL
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 17.0.8
  javaVendor: Alpine
  osName: Linux
  osVersion: 6.1.50-production+truenas
  osArchitecture: amd64
  availableProcessors: 32
  freeMemory: 228349472
  totalMemory: 620756992
  uptime: 48828
  startLevel: 100
addons:
  - automation-jsscripting
  - binding-astro
  - binding-bigassfan
  - binding-chromecast
  - binding-mielecloud
  - binding-network
  - binding-nibeuplink
  - binding-openweathermap
  - binding-solaredge
  - binding-tradfri
  - binding-zwave
  - misc-homekit
  - persistence-influxdb
  - persistence-rrd4j
  - transformation-map
  - ui-basic
  - ui-habpanel
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 8
    language: nl-NL
    languages:
      - nl-NL
      - nl
      - en-US
      - en
      - de
    onLine: true
    platform: MacIntel
  screen:
    width: 1680
    height: 1050
    colorDepth: 30
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
    (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
timestamp: 2023-10-20T08:34:31.427Z
openhab-bot commented 1 year ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/really-struggling-with-miele-cloud-number-of-threads-in-docker/144919/7

wborn commented 1 year ago

You can fix this by reconfiguring the parameters in conf/services/runtime.cfg:

https://github.com/openhab/openhab-distro/blob/678720a9db8f9a7cfa6bb5f1f0e51666eaa9dcc6/distributions/openhab/src/main/resources/conf/services/runtime.cfg#L278-L286

robkamp commented 1 year ago

I changed both conf/services/runtime.cfg and dist/conf/services/runtime.cfg.

I then restarted the container. Tried the mielecloud authentication and had the same error.

The conf/services/runtime.cfg still shows the org.openhab.webclient:maxThreadsCustom = 80 but the dist/conf/services/runtime.cfg was overwritten due to restarting the container as this part is not persisted.

wborn commented 1 year ago

You'll only need to update conf/services/runtime.cfg

Did you also uncomment the lines by removing the # ?

After uncommenting the lines you can check that the values have been applied on the console:

openhab> config:list "(service.pid=org.openhab.webclient)"                                                                                                                                                                             
----------------------------------------------------------------
Pid:            org.openhab.webclient
BundleLocation: null
Properties:
   maxThreadsCustom = 40
   maxThreadsShared = 80
   minThreadsCustom = 20
   minThreadsShared = 20
   service.pid = org.openhab.webclient
robkamp commented 1 year ago

These parameters were not in the conf/services/runtime.cfg so I had to copy them in.

After restartting the container they say what you showed:

openhab> config:list "(service.pid=org.openhab.webclient)"
----------------------------------------------------------------
Pid:            org.openhab.webclient
BundleLocation: null
Properties:
   maxThreadsCustom = 40
   maxThreadsShared = 80
   minThreadsCustom = 20
   minThreadsShared = 20
   service.pid = org.openhab.webclient

I tried the pairing again and it worked.

robkamp commented 1 year ago

Can this configuration be automated for a deployment on a system with many cores, like mine? I have been struggling for more than half a year with this, so now I might be the only one but in the future there might be more.

wborn commented 1 year ago

Insufficient configured threads: required=16 < max=10 for QueuedThreadPool[OH-httpClient-OAuthConnector]

Maybe we can use similar logic as Jetty to automatically determine the lower bounds of these values. That way users do not need to reconfigure the values on computers with a lot of cores.