documentation
NetFUNNEL
Server Side Agent (SSA) v.1.0.0

Server Side Agent (SSA) v.1.0.0

A server-specific agent that can apply the queue service by communicating with the NetFUNNEL server for specific pages among incoming requests to the server. By inserting the agent application code, you can use the virtual waiting room.

How It Works

The NetFUNNEL server side dynamic agent has the following operational flow:

SSA 동작 흐름도

  1. Requests the configuration information needed for rule matching.
  2. Finds matching rules for incoming server requests using the received rule configuration information.
  3. If a match is found, it sends an entry request to the Netfunnel server and receives a response code about whether entry is allowed.
  4. Depending on the received response code, it either moves to the waiting room or processes immediate entry so that the real user's Application Logic operates.

Entry Method from the Waiting Room Once moved to the waiting room page, it operates as follows:

  1. Periodically requests Netfunnel server to check if entry is possible.
  2. If entry is possible, it processes entry to the actual requested page.

How to Apply the Agent

Java

Log in to the NF Console, then go to the server-side agent page via the agent tab and apply according to the order mentioned in the guide document. ⭐️ Assumes using springboot v3.0 or higher.

📁 Download File List

  • netfunnel-agent.zip
    • gson-2.9.1.jar
    • netfunnel-agent.jar

Add the downloaded files to your project. Place them under the project libs folder and modify the build.gradle. ⭐️ Assuming the Build Tool is Gradle.

dependencies {
    implementation files('libs/netfunnel-agent.jar', 'libs/gson-2.9.1.jar')
}

How to Apply Interceptor

Step 1. Write the following code in an Interceptor that first receives server requests.

import com.stclab.adapter.NfAdapter;
import com.stclab.adapter.NfAdapterImpl;
import com.stclab.adapter.NfTokenServletServiceImpl;
import com.stclab.adapter.config.NfAdapterConfig;
 
@Component
public class DemoInterceptor implements HandlerInterceptor {
 
 @Override
 public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    NfAdapterConfig.nfServerUrl = "https://nf4-iphash-lb.stclab.com";
    NfAdapterConfig.nfSettingUrl = "https://nf4-iphash-lb.stclab.com/assets/nf-setting/1/nf-setting.json";
    NfAdapterConfig.nfVwrPageUrl = "https://nf4-iphash-lb.stclab.com/assets/vwr-page-url/1/index.html";
    NfAdapterConfig.requestUrl = request.getRequestURL().toString() + (request.getQueryString() != null ? "?" + request.getQueryString() : "");
    
    NfAdapterConfig.retryCount = 1;    // Optional, Default: 1, min: 0
    NfAdapterConfig.networkTimeout = 1000;    // Optional, Default: 1000, min: 0
    NfAdapterConfig.logLevel = Level.INFO;  
    
    NfAdapter nfAdapter = new NfAdapterImpl(new NfTokenServletServiceImpl(request, response));
 
    if (nfAdapter.run()) {
        log.info("Passed through Interceptor");
        return true;
    } else {
        log.error("Blocked by Interceptor");
        return false;
    }
 }
}

Step 2. Register the created interceptor by overriding the addInterceptors method of WebMvcConfigurer.

@Configuration
@RequiredArgsConstructor
public class Webconfig implements WebMvcConfigurer {
 
    private final DemoInterceptor demoInterceptor;
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(demoInterceptor);
    }
}

How to Apply Filter

Step 1. Write the following code in a Filter that first receives server requests.

@Component
public class DemoFilter implements Filter {
 
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
 
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
 
        NfAdapterConfig.nfServerUrl = "https://nf4-iphash-lb.stclab.com";
        NfAdapterConfig.nfSettingUrl = "https://nf4-iphash-lb.stclab.com/assets/nf-setting/1/nf-setting.json";
        NfAdapterConfig.nfVwrPageUrl = "https://nf4-iphash-lb.stclab.com/assets/vwr-page-url/1/index.html";
        NfAdapterConfig.requestUrl = request.getRequestURL().toString() + (request.getQueryString() != null ? "?" + request.getQueryString() : "");
        
        NfAdapterConfig.logLevel = Level.INFO;
 
        NfAdapter nfAdapter = new NfAdapterImpl(new NfTokenServletServiceImpl(request, response));
 
        if (nfAdapter.run()) {
            chain.doFilter(servletRequest, servletResponse);
        }
    }
}

Step 2. Register the created Filter as a bean.

@Configuration
@RequiredArgsConstructor
public class FilterConfig {
    private final DemoFilter demoFilter;
 
    @Bean
    public FilterRegistrationBean<Filter> filterRegistrationBean() {
        return new FilterRegistrationBean<>(demoFilter);
    }
}

NfAdapterConfig Configuration Information

FieldDescriptionMandatory
nfServerUrlSpecify the Netfunnel server address confirmed in NF Console.True
nfSettingUrlSpecify the address of Setting.json confirmed in NF Console.True
nfVwrPageUrlSpecify the Vwr Page address confirmed in NF Console.True
requestUrlSet the URL for incoming server requests.True
retryCountSet the number of retries if an API request fails. If the API request fails the set number of times, it will not retry further.False
networkTimeoutSet the maximum waiting time for an API request in milliseconds (ms). If no response arrives within the set time, the request is considered failed. Setting it to 0 disables the timeout feature.False
logLevelSet the log level of the Agent.False
ℹ️

Except for nfEumUrl, the Url settings in NfAdapterConfig are mandatory, and not setting them will result in a bypass of all requests (such as nfServerUrl, nfSettingUrl, etc).