Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php5-fpm: Connection reset by peer (read) #7

Open
cergfix opened this issue Jul 29, 2015 · 4 comments
Open

php5-fpm: Connection reset by peer (read) #7

cergfix opened this issue Jul 29, 2015 · 4 comments

Comments

@cergfix
Copy link

cergfix commented Jul 29, 2015

The following issue occurs under some circumstances:

[Wed Jul 29 08:17:36 UTC 2015] - INFO: java.io.IOException: Connection reset by peer
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:192)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
    at com.googlecode.fcgi4j.util.IoUtils.socketRread(IoUtils.java:29)
    at com.googlecode.fcgi4j.FCGIConnection.readHeader(FCGIConnection.java:257)
    at com.googlecode.fcgi4j.FCGIConnection.read(FCGIConnection.java:526)

Works OK under HHVM FastCGI, but throws an error when PHP5-FPM is used.

There is a bit of a difference in strace outputs:

PHP5-FPM:

[pid 23018] write(4, "\1\6\0\1\37\370\0\0Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nPragma: no-cache\r\nContent-type: text/html; charset=UTF-8\r\n\r\n<!DOCTYPE html PUBLIC...............

HHVM:

sendmsg(19, {msg_name(0)=NULL, msg_iov(20)=[{"\1\6\0\1\377\377\1\1", 8}, {"Content-Type: text/html\r\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\r\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nVary: Accept-Encoding\r\nPragma: no-cache\r\n\r\n<!DOCTYPE html PUBLIC...............

Also, enabling Xhprof in PHP5-FPM fixes the issue.

@cergfix
Copy link
Author

cergfix commented Sep 28, 2015

The issue occurs when content data (POST) push is executed while the request method is set to GET.

Use a condition:

String requestMethod = "GET";
connection.setRequestMethod(requestMethod);
if(requestMethod.equalsIgnoreCase("POST")){
    connection.setContentLength(postData.length);
    connection.write(ByteBuffer.wrap(postData));
}

This issue affects PHP5-FPM only.

@Nyholm
Copy link
Member

Nyholm commented Sep 28, 2015

Okey. That is great that you have been troubleshooting.
Can you send a PR?

@cergfix
Copy link
Author

cergfix commented Sep 28, 2015

Working on it :)

@Nyholm
Copy link
Member

Nyholm commented Sep 28, 2015

You are awesome!

cergfix pushed a commit to cergfix/fcgi4j that referenced this issue Sep 28, 2015
cergfix pushed a commit to cergfix/fcgi4j that referenced this issue Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants