azuredockerterraformazure-container-instanceslightstreamer

Lightstreamer on Azure Container Instances using Terraform


I'm trying to deploy a Lightstreamer Docker Instance to Azure Container Groups.

My adapters.xml config is as follows:

<?xml version="1.0"?>

<adapters_conf id="SHOWCASE">

  <metadata_provider>
    <adapter_class>com.lightstreamer.adapters.metadata.LiteralBasedProvider</adapter_class>
  </metadata_provider>

  <data_provider>
    <adapter_class>ROBUST_PROXY_FOR_REMOTE_ADAPTER</adapter_class>
    <classloader>log-enabled</classloader>
    <param name="request_reply_port">6661</param>
    <param name="notify_port">6662</param>
  </data_provider>

</adapters_conf>

The Dockerfile is structured like:

FROM lightstreamer:7.0

COPY ["adapters.xml", "/lightstreamer/adapters/proxy/"]

and last but not least my terraform file looks like this:

 resource "azurerm_container_group" "lightstreamer" {
     name = "${var.organization}-${var.project}-lightstreamer"
     depends_on = [
       azurerm_container_registry.container_registry
     ]
     location = var.location
     resource_group_name = azurerm_resource_group.resource_group.name
     ip_address_type = "Public"
     os_type = "Linux"
     container {
       name = "lightstreamer-web"
       image = "${azurerm_container_registry.container_registry.login_server}/lightstreamer:${var.image_tag}"
       cpu = "0.5"
       memory = "1.5"
       ports {
         port = 8080
         protocol = "TCP"
       }
       ports {
         port = 6661
         protocol = "TCP"
       }
       ports {
         port = 6662
         protocol = "TCP"
       }
     }
     exposed_port = [
       {
           port = 8080
           protocol = "TCP"
       },
       {
           port = 6661
           protocol = "TCP"
       },
       {
           port = 6662
           protocol = "TCP"
       }
     ]
     image_registry_credential {
         server = "${azurerm_container_registry.container_registry.login_server}"
         username = "${azurerm_container_registry.container_registry.admin_username}"
         password = "${azurerm_container_registry.container_registry.admin_password}"
     }    
     dns_name_label = "${var.organization}-${var.project}-lightstreamer"
 }

Unfortunately, whenever I add the exposed ports 6661 and 6662 to the terraform (I need them due to the adapters.xml), the Lightstreamer runs into an error:

09.Aug.22 17:48:41,358 < INFO> Request sender 'SHOWCASE.DEFAULT' starting...
09.Aug.22 17:48:41,372 < INFO> Reply receiver 'SHOWCASE.DEFAULT' starting...
09.Aug.22 17:48:44,232 < INFO> Request sender 'SHOWCASE.DEFAULT' stopped
09.Aug.22 17:48:44,235 <ERROR> Exception caught while trying to initialize the Remote Server
com.lightstreamer.adapters.proxy.request_reply.DisconnectedException: Connection closed while waiting for an answer to request 10000018283b91608
    at com.lightstreamer.adapters.proxy.request_reply.RequestSender.quit(RequestSender.java:175)
    at com.lightstreamer.adapters.proxy.BaseRemoteProvider.stop(BaseRemoteProvider.java:100)
    at com.lightstreamer.adapters.proxy.data.RobustNetworkedDataProvider$RecoverableNDP.onInnerException(RobustNetworkedDataProvider.java:390)
    at com.lightstreamer.adapters.proxy.data.RobustNetworkedDataProvider$RecoverableNDP.access$400(RobustNetworkedDataProvider.java:258)
    at com.lightstreamer.adapters.proxy.data.RobustNetworkedDataProvider$RecoverableNDP$1.onException(RobustNetworkedDataProvider.java:375)
    at com.lightstreamer.adapters.proxy.request_reply.NotifyReceiver.run(NotifyReceiver.java:110)
09.Aug.22 17:48:44,236 <ERROR> Exception from the inner Proxy Data Adapter: com.lightstreamer.interfaces.data.DataProviderException: Connection closed while waiting for an answer to request 10000018283b91608
09.Aug.22 17:48:44,236 <ERROR> Got fatal error from the inner Proxy Data Adapter
com.lightstreamer.adapters.proxy.RemotingException: Unexpected end of reply stream reached
    at com.lightstreamer.adapters.proxy.request_reply.NotifyReceiver.run(NotifyReceiver.java:110)
Caused by: java.io.EOFException: null
    ... 1 common frames omitted
09.Aug.22 17:48:44,236 < INFO> Reply receiver 'SHOWCASE.DEFAULT' stopped
09.Aug.22 17:48:44,237 <ERROR> Inner Proxy Data Adapter initialization failure; no Inner Proxy will be used

Locally it just runs fine, but whenever it's hosted on ACI this error occurs.


Solution

  • After rebuilding the whole approach with Amazon Web Services, it turned out that some health probes were causing the same issue at AWS. So I've changed the probes to point to the default http (8080) port instead of the configured ports 6661 and 6662 and it started working (at AWS).

    Unfortunately I couldn't configure the probes for each port on Azure, so I've decided to move the whole instance into a private network.

    Therefore, I've changed the terraform as follows:

         ip_address_type = "Private"
    

    and added these resources:

    resource "azurerm_virtual_network" "default" { ... }
    
    resource "azurerm_subnet" "lightstreamer" {
      name = "lightstreamer"
      depends_on = [
        azurerm_virtual_network.default
      ]
      resource_group_name = azurerm_resource_group.resource_group.name
      virtual_network_name = azurerm_virtual_network.default.name
      address_prefixes = [ "172.16.1.0/24" ]
      delegation {
        name = "delegation"
        service_delegation {
          name = "Microsoft.ContainerInstance/containerGroups"
          actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
        }
      }
    }
    
    resource "azurerm_network_profile" "default" {
        name =  "ls-profile"
        depends_on = [
          azurerm_subnet.lightstreamer
        ]
        #location = "${var.location}"
        location = "westeurope"
        resource_group_name = "${azurerm_resource_group.resource_group.name}"
        container_network_interface {
          name = "ls-nic"
          ip_configuration {
            name = "default"
            subnet_id = "${azurerm_subnet.lightstreamer.id}"
          }
        }  
    }
    
    

    This time the Lightstreamer started fine, enabling me to add an Application Gateway in order to provide public access.