FastCGI via C : FCGX_Accept_r occasionally perform “Connection reset…”










-2















I have a single-threaded FastCGI "Hello, World!" application, there are some code:



error = FCGX_Init();
// error handling

socket_descriptor = FCGX_OpenSocket("127.0.0.1:1500", 5);
// error handling

error = FCGX_InitRequest(&request, socket_descriptor, 0);
// error handling

std::cout << "Awaiting connect...";
bytes_accepted = FCGX_Accept_r(&request);
// error handling
std::cout << "OK!" << std::endl;

FCGX_PutS("<title>Hello!</title>rn", request.out)

FCGX_Finish_r(&request);


When I launch this code, open browser and do "127.0.0.1:1500", browser says "Connection reset" and code outputs nothing like "OK", FCGX_Accept_r seems to be freezing.



I tried to open appropriate port on my Debian 9 x64 with an iptables:



iptables -A INPUT -i eth0 -p tcp --destination-port 1500 -j ACCEPT
iptables-save


but it causes no effect.



What am I doing wrong?










share|improve this question






















  • Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

    – eerorika
    Nov 13 '18 at 10:16











  • Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:18












  • So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:25















-2















I have a single-threaded FastCGI "Hello, World!" application, there are some code:



error = FCGX_Init();
// error handling

socket_descriptor = FCGX_OpenSocket("127.0.0.1:1500", 5);
// error handling

error = FCGX_InitRequest(&request, socket_descriptor, 0);
// error handling

std::cout << "Awaiting connect...";
bytes_accepted = FCGX_Accept_r(&request);
// error handling
std::cout << "OK!" << std::endl;

FCGX_PutS("<title>Hello!</title>rn", request.out)

FCGX_Finish_r(&request);


When I launch this code, open browser and do "127.0.0.1:1500", browser says "Connection reset" and code outputs nothing like "OK", FCGX_Accept_r seems to be freezing.



I tried to open appropriate port on my Debian 9 x64 with an iptables:



iptables -A INPUT -i eth0 -p tcp --destination-port 1500 -j ACCEPT
iptables-save


but it causes no effect.



What am I doing wrong?










share|improve this question






















  • Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

    – eerorika
    Nov 13 '18 at 10:16











  • Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:18












  • So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:25













-2












-2








-2








I have a single-threaded FastCGI "Hello, World!" application, there are some code:



error = FCGX_Init();
// error handling

socket_descriptor = FCGX_OpenSocket("127.0.0.1:1500", 5);
// error handling

error = FCGX_InitRequest(&request, socket_descriptor, 0);
// error handling

std::cout << "Awaiting connect...";
bytes_accepted = FCGX_Accept_r(&request);
// error handling
std::cout << "OK!" << std::endl;

FCGX_PutS("<title>Hello!</title>rn", request.out)

FCGX_Finish_r(&request);


When I launch this code, open browser and do "127.0.0.1:1500", browser says "Connection reset" and code outputs nothing like "OK", FCGX_Accept_r seems to be freezing.



I tried to open appropriate port on my Debian 9 x64 with an iptables:



iptables -A INPUT -i eth0 -p tcp --destination-port 1500 -j ACCEPT
iptables-save


but it causes no effect.



What am I doing wrong?










share|improve this question














I have a single-threaded FastCGI "Hello, World!" application, there are some code:



error = FCGX_Init();
// error handling

socket_descriptor = FCGX_OpenSocket("127.0.0.1:1500", 5);
// error handling

error = FCGX_InitRequest(&request, socket_descriptor, 0);
// error handling

std::cout << "Awaiting connect...";
bytes_accepted = FCGX_Accept_r(&request);
// error handling
std::cout << "OK!" << std::endl;

FCGX_PutS("<title>Hello!</title>rn", request.out)

FCGX_Finish_r(&request);


When I launch this code, open browser and do "127.0.0.1:1500", browser says "Connection reset" and code outputs nothing like "OK", FCGX_Accept_r seems to be freezing.



I tried to open appropriate port on my Debian 9 x64 with an iptables:



iptables -A INPUT -i eth0 -p tcp --destination-port 1500 -j ACCEPT
iptables-save


but it causes no effect.



What am I doing wrong?







c++ c fastcgi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 10:04









Ovoshnoe RagooOvoshnoe Ragoo

13




13












  • Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

    – eerorika
    Nov 13 '18 at 10:16











  • Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:18












  • So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:25

















  • Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

    – eerorika
    Nov 13 '18 at 10:16











  • Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:18












  • So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

    – Ovoshnoe Ragoo
    Nov 13 '18 at 10:25
















Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

– eerorika
Nov 13 '18 at 10:16





Fastcgi isn't HTTP. Perhaps the browser doesn't understand the protocol.

– eerorika
Nov 13 '18 at 10:16













Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

– Ovoshnoe Ragoo
Nov 13 '18 at 10:18






Am I not just sending data which browser can interpret as a plain text? What about "Content-type: text/html" prefix? It doesn't work too.

– Ovoshnoe Ragoo
Nov 13 '18 at 10:18














So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

– Ovoshnoe Ragoo
Nov 13 '18 at 10:25





So the failure is before sending text, it's in the FCGX_Accept_r freezing call.

– Ovoshnoe Ragoo
Nov 13 '18 at 10:25












1 Answer
1






active

oldest

votes


















0














When you don't specify a schema in the url and the port isn't specific to any particular protocol that the browser understands, so the browser will assume http:// (or maybe https these days?). Your program expects fastcgi instead, which is a different protocol, and the library doesnt understand HTTP. Probably the request will never be accepted.



Fastcgi is a protocol for communicating with a web server. You need to use a web server that accepts http requests an forwards those requests using fastcgi protocol. For example, nginx supports the protocol.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278457%2ffastcgi-via-c-fcgx-accept-r-occasionally-perform-connection-reset%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    When you don't specify a schema in the url and the port isn't specific to any particular protocol that the browser understands, so the browser will assume http:// (or maybe https these days?). Your program expects fastcgi instead, which is a different protocol, and the library doesnt understand HTTP. Probably the request will never be accepted.



    Fastcgi is a protocol for communicating with a web server. You need to use a web server that accepts http requests an forwards those requests using fastcgi protocol. For example, nginx supports the protocol.






    share|improve this answer



























      0














      When you don't specify a schema in the url and the port isn't specific to any particular protocol that the browser understands, so the browser will assume http:// (or maybe https these days?). Your program expects fastcgi instead, which is a different protocol, and the library doesnt understand HTTP. Probably the request will never be accepted.



      Fastcgi is a protocol for communicating with a web server. You need to use a web server that accepts http requests an forwards those requests using fastcgi protocol. For example, nginx supports the protocol.






      share|improve this answer

























        0












        0








        0







        When you don't specify a schema in the url and the port isn't specific to any particular protocol that the browser understands, so the browser will assume http:// (or maybe https these days?). Your program expects fastcgi instead, which is a different protocol, and the library doesnt understand HTTP. Probably the request will never be accepted.



        Fastcgi is a protocol for communicating with a web server. You need to use a web server that accepts http requests an forwards those requests using fastcgi protocol. For example, nginx supports the protocol.






        share|improve this answer













        When you don't specify a schema in the url and the port isn't specific to any particular protocol that the browser understands, so the browser will assume http:// (or maybe https these days?). Your program expects fastcgi instead, which is a different protocol, and the library doesnt understand HTTP. Probably the request will never be accepted.



        Fastcgi is a protocol for communicating with a web server. You need to use a web server that accepts http requests an forwards those requests using fastcgi protocol. For example, nginx supports the protocol.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 10:33









        eerorikaeerorika

        78.3k556119




        78.3k556119



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278457%2ffastcgi-via-c-fcgx-accept-r-occasionally-perform-connection-reset%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands