4 Replies Latest reply on Jun 15, 2015 12:16 PM by hmoore

    TCP server crash  - on reception of large number of data's

      Hi

       

      I just modified the tcp_server app

      1. Once connected listens for data until disconnected from client side

      2. Removed the echo back , prints the rxd pkt size only

      I'm transmitting packets of 1K size to the server continuously without delays , and after some time ,say 30 sec , I see my server gets crashed and Platform gets restarted,

       

      This behavior is only in Wiced SDK 3.1.0 but working OK in Wiced SDK 2.4.1 , But I can't use SDK 2.4.1.

      How can I solve this issue? Do I require some patches to solve this problem?

       

      static wiced_result_t tcp_server_process(  tcp_server_handle_t* server, wiced_packet_t* rx_packet )
      {
          char*          request;
          uint16_t        request_length;
          uint16_t        available_data_length;
      
          wiced_packet_get_data( rx_packet, 0, (uint8_t**) &request, &request_length, &available_data_length );
          WPRINT_APP_INFO(("%d\n", request_length)); /* just prints the length of xrd packet*/
          return WICED_SUCCESS;
      }
      
      static void tcp_server_thread_main(uint32_t arg)
      {
          tcp_server_handle_t* server = (tcp_server_handle_t*) arg;
          while ( quit != WICED_TRUE )
          {
              wiced_packet_t* temp_packet = NULL;
              wiced_result_t result = wiced_tcp_accept( &server->socket );
              if ( result == WICED_SUCCESS )
              {
                  while(1)
                  {
                      if (wiced_tcp_receive( &server->socket, &temp_packet, WICED_WAIT_FOREVER ) == WICED_SUCCESS)
                      {
                          /* Process the client request */
                          tcp_server_process( server, temp_packet );
                          /* Delete the packet, we're done with it */
                          wiced_packet_delete( temp_packet );
                      }
                      else
                      {
                          wiced_tcp_disconnect( &server->socket );
                          break;
                      }
                  }
              }
          }
          WPRINT_APP_INFO(("Disconnect\n"));
          WICED_END_OF_CURRENT_THREAD( );
      }
      
      
      
        • 1. Re: TCP server crash  - on reception of large number of data's

          I think that you missed function call tcp_packet_delete

           

          Hi

           

          try this sample for your information

          //-----------------------------------------------------------------------------

          static wiced_result_t tcp_server_process(  tcp_server_handle_t* server, wiced_packet_t* rx_packet ) 

              char*          request; 

              uint16_t        request_length; 

              uint16_t        available_data_length; 


              wiced_packet_get_data( rx_packet, 0, (uint8_t**) &request, &request_length, &available_data_length ); 

              WPRINT_APP_INFO(("%d\n", request_length)); /* just prints the length of xrd packet*/ 

          //----------------------- add this code  -----------------------------------------------------------------------------

            wiced_packet_delete(rx_packet); // delete packet data(alloced memmory )

          //-------------------------------------------------------------------------------------------------------------------------

              return WICED_SUCCESS; 



           


          • 2. Re: TCP server crash  - on reception of large number of data's

            But as you can see that the packet gets deleted after calling the function tcp_server_process()

             

            if (wiced_tcp_receive( &server->socket, &temp_packet, WICED_WAIT_FOREVER ) == WICED_SUCCESS) 

                /* Process the client request */ 

                tcp_server_process( server, temp_packet ); 

                /* Delete the packet, we're done with it */ 

                wiced_packet_delete( temp_packet ); 

            }


            So I assume this is enough to deallocate the alloacated memory for TCP packets.


             

            • 3. Re: TCP server crash  - on reception of large number of data's

              Yes,  I missed,

               

              how about  "tcp_server_thread_main" stack size ?

               

              Then try "making thread stack_size", WICED seems to use more stack in network applicaiton.

               

              TKS

              • 4. Re: TCP server crash  - on reception of large number of data's

                Discussion is being locked. If you have any follow-up questions, please start a new discussion.