AnsweredAssumed Answered

Can't open HTTPSRV web pages. Explorer keeps in waiting

Question asked by Kaiyue Yang on Sep 25, 2013
Latest reply on Nov 24, 2013 by Kaiyue Yang

My chip is K60DN512. I was using MQX3.8 & HTTPD before, and it works well. I updated MQX to 4.2 and switched to HTTPSRV last week. Then I can't open the web pages any more. My project is using HTTPSRV, socket and ftp client. Socket and ftp client works well without HTTPSRV .

 

If I disable socket and ftp, the web pages can be opened. But the explorer will get a error page "can't connect the server" half the time.

 

I've traced the program. It seems stuck in httpsrv_server_task():

    /* Get socket with incoming connection (IPv4 or IPv6) */
    while (!connsock && server->run)
    {
        connsock = RTCS_selectset(&(server->sock_v4), 2, 250);
    }
  
    if (server->run)
    {
        struct sockaddr  remote_addr;
        unsigned short   length;

 

        new_sock = accept(connsock, (sockaddr *) &remote_addr, &length);
        connsock = 0;
    }
    else
    {
        break;
    }

 

 

Here is my rtcs init function:

 

uint_32 RTCS_Init(void)
{
    int_32            error;
    _enet_address     address;
        
    IPCFG_IP_ADDRESS_DATA ip_data;
    extern const HTTPSRV_CGI_LINK_STRUCT cgi_lnk_tbl[];
    extern const TFS_DIR_ENTRY tfs_data[];
    HTTPSRV_PARAM_STRUCT params;
    char index[20];

    /* runtime RTCS configuration */
    _RTCSPCB_init = 4;
    _RTCSPCB_grow = 2;
    _RTCSPCB_max = 10;
    _RTCS_msgpool_init = 4;
    _RTCS_msgpool_grow = 2;
    _RTCS_msgpool_max  = 10;
    _RTCS_socket_part_init = 4;
    _RTCS_socket_part_grow = 2;
    _RTCS_socket_part_max  = 10;
    _RTCSTASK_stacksize = 6000;
//    _int_install_unexpected_isr();
    
    //start rtcs
    error = RTCS_create();
    _IP_forward = TRUE;
    ENET_get_mac_address(DEMOCFG_DEFAULT_DEVICE, ENET_IPADDR, address);
    if (error != RTCS_OK)
    {
        printf("rtcs error1\n");
        return ERMD_RTCS_INIT_ERROR;
    }

    error = ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, address);
    ip_data.ip      = ENET_IPADDR;
    ip_data.mask    = ENET_IPMASK;
    ip_data.gateway = ENET_GATEWAY;
    error = ipcfg_bind_staticip (DEMOCFG_DEFAULT_DEVICE, &ip_data);
    if (error != RTCS_OK)
    {
        printf("rtcs error2\n");
        return ERMD_RTCS_INIT_ERROR;
    }
    //set ip address
    //set web page data
    error = _io_tfs_install("tfs:", tfs_data);
    if (error != RTCS_OK)
    {
        return ERMD_RTCS_INIT_ERROR;
    }
    /* Start HTTP server on each interface */
        _mem_zero(&params, sizeof(HTTPSRV_PARAM_STRUCT));
        snprintf(index, 20, "\\hardware.html");
        params.af = AF_INET;  //IPv4, IPv6 or from config.h
        params.root_dir = "tfs:";
        params.index_page = index;
        params.auth_table = auth_realms;
        
        /*
        ** If there is only one server listen on any IP address 
        ** so address can change in runtime (DHCP etc.).
        ** Otherwise we will use static IP for server.
        */
//        params.ipv4_address.s_addr = ENET_IPADDR;
        params.ipv4_address.s_addr = INADDR_ANY;
            /* Print active IPv4 address */
        /*
        ** Maximum default number of available sockets in RTCS is six.
        ** Maximum of two are used for HTTP server as listening sockets (one for IPv4 and one for IPv6).
        ** So we take two of sockets and use them for sessions.
        */
        params.max_ses = 2;
        params.cgi_lnk_tbl = (HTTPSRV_CGI_LINK_STRUCT*) cgi_lnk_tbl;

        /* There are a lot of static data in CGIs so we have to set large enough stack for script handler */
//        params.script_stack = 100;
        server = HTTPSRV_init(&params);
        if (server == NULL)
        {
            printf("HTTPSRV Init err\n");
        }
        
    
    
    return ERMD_OK;
}

Outcomes