Problem with dynamic ports on Luxure and Cosock servers after HUB restart

Hello, I have a problem with luxure and cosock servers.
Every time the HUB is restarted, a new PORT is assigned to the server. This is quite problematic for the other device, how can I solve this?

local lux = require('luxure')
local cosock = require('cosock').socket
local json = require('dkjson')
local capabilities = require "st.capabilities"
local log = require "log"
local hub_server = {}

function hub_server.start(driver)
    local server = lux.Server.new_with(cosock.tcp(), {env='debug'})

    -- Register server
    driver:register_channel_handler(server.sock, function ()

    -- Endpoint
    server:get('/pm/:power/:energy/:device', function (req, res)
        local power = req.params.power
        local energy =
        local dev_id = req.params.device"Empfang: "..power.."W")"Empfang: ""W")
        local device = driver:get_device_info(dev_id)
        device:emit_event(capabilities.powerMeter.power({value = tonumber(power), unit = "W"}))
        device:emit_event({value = tonumber(energy), unit = "kWh"}))
        res:send('HTTP/1.1 200 OK')

    server:listen()"Server hört zu! Port: ".. server.port)
    driver.server = server

return hub_server

Hi, @Hellerqr

This is the expected behavior, when the Hub is restarted, a new connection will be created and the port is changed.
TCP sockets cannot request a specific port for binding because it’s not allowed for both usability and security reasons.
Since only a single pool of ports is available for all processes, we cannot guarantee two drivers won’t try to use the same port.
Allowing the bind request’s port to be configured by the user would complicate the user experience in systems with several LAN drivers, and it would also expose potential side channels to escape sandbox boundaries