compact framework - Padarn OpennetCF Socket Connection is Closed -


i'm evaluating padarn project , i'm trying implement simple example. need padarn win ce 5.0 or 6.0 web project , bought license configuration part :

    static void main(string[] args)     {              m_padarnserver = new webserver();             m_padarnserver.start();     } 

and render function:

  protected override void render(htmltextwriter writer)     {                          if (response.isclientconnected)             {                 response.write("ok");                 response.flush();                 writer.flush();             }      } 

and config file :

 <?xml version="1.0" encoding="utf-8" ?>  <configuration>  <configsections> <section name="webserver"   type="opennetcf.web.configuration.serverconfigurationhandler, opennetcf.web" /> <section name ="httpruntime" type ="opennetcf.web.configuration.httpruntimeconfigurationhandler, opennetcf.web"/> <section name="log4net" type="log4net.config.log4netconfigurationsectionhandler, log4net"/>          </configsections>   <webserver    defaultport="80"    maxconnections="20"    documentroot="\nandflash\inetpub\"    logging="true"    logfolder="\temp\logs"    logextensions="aspx;html;htm;zip"    usessl="false"    >   <defaultdocuments>   <document>default.aspx</document>   </defaultdocuments>   <virtualdirectories />   <cookies />   <caching />   </webserver>   <httpruntime   maxrequestlength="3000000"   requestlengthdiskthreshold="256"   />  <requestlimits maxallowedcontentlength="2097151000"/>   </configuration> 

and socket connection checker :

  private static bool isportopen()     {         tcpclient tcpclient = new tcpclient();                     try         {             tcpclient.connect("127.0.0.1", 80);                             return true;         }         catch (exception)         {             return false;         }     } 

i'm checking socket connection padarn run on ( 127.0.0.1 : 80 ) periodically (every 5 seconds) padarn server down !!! , can't connect ,when check socket's port , disconnected , have restart padarn

please me , configuration wrong ? what's problem ?

the problem believe tcpclients never explicitly disconnected or closed, each call isportopen tcp connection created , left open.

at point web server reaches maximum number of concurrent requests configured handle (20?), or client runs out of resources , unable create more connections.

things sort out web server may decide close inactive connections, or garbage collector on connecting client may start cleaning tcpclient instances have gone out of scope, invoking close/dispose methods along way , closing underlying connections.

the fact restarting padarn solves issue shows web server runs out of resources first (or starts rejecting connections when maximum number has been reached).

try explicitly closing each connection:

private static bool isportopen() {     using(tcpclient tcpclient = new tcpclient())     {         try         {             tcpclient.connect("127.0.0.1", 80);             return true;         }         catch(exception)         {             return false;         }     } } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -