FastCGI via C : FCGX_Accept_r occasionally perform “Connection reset…”
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
add a comment |
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
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
add a comment |
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
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
c++ c fastcgi
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 13 '18 at 10:33
eerorikaeerorika
78.3k556119
78.3k556119
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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