LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Debug Router

The light-router instance serves the Single Page Application and acts as a proxy and load balancer to access the APIs behind it. From the previous login-view, we have seen the complicated interactions between the Single Page Application, Login View of OAuth 2.0 provider, and the StatelessAuthHandler wired in the light-router chain. This puts the light-router as a central point in the entire application. To solve issues with the UI, and microservices, it is easier to debug into the router instance.

There are two ways to debug light-docker.

Local Standalone

As the light-4j application is just a POJO without any container, you can debug locally just like a simple Java application with the entry point as com.networknt.server.Server. If you are using the externalized configuration folder, then you can add an option as -Dlight-4j-config-dir=xxx

The config folder for the standalone debug is located at https://github.com/networknt/light-config-test/tree/master/light-router/local-openbanking/debug

The only file that is different than the normal config folder is the virtual-host.yml file.

hosts:
  - domain: obsignin.lightapi.net
    path: /
    base: /home/steve/networknt/light-config-test/light-router/local-openbanking/obsignin/build
    #base: /obsignin/build
    transferMinSize: 10245760
    directoryListingEnabled: false
  - domain: ob.lightapi.net
    path: /
    base: /home/steve/networknt/light-config-test/light-router/local-openbanking/ob/build
    #base: /ob/build
    transferMinSize: 10245760
    directoryListingEnabled: false

Notice that we are using the absolute path for the base to load the two single-page applications.

Remote Docker Container

Sometimes, the application might work well in standalone mode but doesn’t work inside a docker container. In most cases, this is due to the docker network issue. A lot of developers are getting used to the localhost and don’t know that the same localhost points to the docker OS loopback address instead of the docker host address.

To resolve issues in the docker container, you can connect to the application within the docker container to debug remotely.

The configuration folder for the docker remote debug is located at https://github.com/networknt/light-config-test/tree/master/light-router/local-openbanking/config

In the local-openbanking folder, we have a docker-compose-debug.yml that is loading the container with the debug tag.

version: '2'

services:

  light-router:
    image:  networknt/light-router:debug
    ports:
    - 8443:8443
    extra_hosts:
    - "obsignin.lightapi.net:192.168.1.144"
    - "ob.lightapi.net:192.168.1.144"
    volumes:
    - ./config:/config
    - ./obsignin/build:/obsignin/build
    - ./ob/build:/ob/build
    network_mode: host

To create the light-router debug docker image.

cd ~/networknt/light-router
mvn clean install -DskipTests
docker build -t networknt/light-router:debug -f ./docker/Dockerfile-Debug .

Once the local-openbanking works, we need to deploy everything to the test cloud so that the demo application can be accessed from the Internet.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Debug Router” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute