javascript - Cannot connect to dlib webserver remotely, localhost does work -


i developing html/javascript frontend c++ backend doing calculations. both connected via integrated small dlib webserver handles requests. frontend requests data this:

pop=$.ajax({ //load population array of 90         type:"post",         url: "pop90",         async:false         });     eval(pop.responsetext); 

the webserver returns large array (length around 4 000 000) in single string. works if connect via localhost, cannot access server remotely on computer. browser loads while , times out, can see requests on server. server throws error: dlib.server_http: http field client long. http request client should not big, actual post server is. thx lot in advance! elaborate bit more. tested page in firefox, doesn't work via localhost. error console sais array initializer, respinse string of webserver , goes this, 4 million entries:

"ar=[-99999, -99999, ...]"  

the webserver class handles request looks this:

    class web_server : public server_http {     vector<vector<double>> pop90;     vector<vector<double>> pop95;     vector<vector<double>> pop00;     public: web_server::web_server()         {         cout<<"init...";         loadarray("data/raw/afp90g.asc", &pop90);         cout<<" 90 loaded...";         loadarray("data/raw/afp95g.asc", &pop95);         cout<<" 95 loaded...";         loadarray("data/raw/afp00g.asc", &pop00);         cout<<" 00 loaded...";         cout<<"ready!"<<endl;         }     const std::string on_request (const incoming_things& incoming, outgoing_things& outgoing)         {         cout<<"---------------------------"<<endl;         cout<<incoming.path<<endl;         ostringstream sout;         sout<<get_file_contents("seite.html");         cout<<"content type: "<<incoming.content_type<<endl;         cout<<"request type: "<<incoming.request_type<<endl;         string filename=incoming.path.substr(1,incoming.path.length());          if (incoming.path.substr(0,1) == "/" && incoming.path.length()>1)             {             if (incoming.path=="/css/style.css") outgoing.headers["content-type"] == "text/css";             if (incoming.path.substr(0,8)=="/pop90") return parsearray(pop90);             if (incoming.path.substr(0,8)=="/pop95") return parsearray(pop95);             if (incoming.path.substr(0,8)=="/pop00") return parsearray(pop00);             return get_file_contents(filename.c_str());             }         return sout.str();         } }; 

ok, tinkered bit server_http.cpp file create full dump of incoming stream. seams though there randomly -1 values (eof) in between fine http messages long connect locally. if connect remotely via actual ip theres -1 values coming in. deactivated firewall/antivirus. port forwarding should ok. still habe no idea do.

to prevent clients flooding server , exhausting memory, dlib's web server has limit on length of http headers , query path string. specifically, requires each individually less 16kb in length , if client tries send more gives "http field client long" error message seeing.

so must somehow generating long path or maybe sending large header (perhaps big cookie creating?). can change 16kb limit else editing line 129 in dlib/server/server_http.cpp. better if settable calling member function (since i'm author of dlib :) ) i'll make feature in next release.

but in event, it's surprising hitting 16kb limit since that's pretty big limit considering usual lengths of path string , http headers. there might else going on in http client code.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -