Problems with HTTP/2

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with HTTP/2

Aapo Talvensaari
I tried the 1.9.5 release with http2 and it worked fine, but Ajax request especially were problematic.

I did get errors like:
net::ERR_SPDY_COMPRESSION_ERROR

And the status code was 0. With the former spdy support I didn't have any problems. I'm also using fastcgi and PHP5 in this server where I tried it. What could cause these problems?


Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

vedranf
Have you seen this one
http://forum.nginx.org/read.php?29,261735,261737#msg-261737
Have you completely removed the spdy module ?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,261745,261750#msg-261750

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 23 September 2015 at 11:48, itpp2012 <[hidden email]> wrote:
> Have you seen this one
> http://forum.nginx.org/read.php?29,261735,261737#msg-261737
> Have you completely removed the spdy module ?

I have seen that, but I'm using the official Ubuntu precise packages from nginx.org, so I kinda think it should be totally removed. I also removed all the spdy settings from configs. It seems that either there is some magical configs somewhere or that http/2 is buggy. Or that it is buggy only with fastcgi + PHP-FPM. Normal requests seems fine, but using Backbone.js / jQuery AJAX calls, leads to errors. I suspect the POST/PUT requests are the most problematic, because GET requests seem to work. I will do further testing at some point. Still, I never had any of these problems with Nginx+SPDY.

Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Valentin V. Bartenev-3
In reply to this post by Aapo Talvensaari
On Wednesday 23 September 2015 06:28:37 Aapo Talvensaari wrote:

> I tried the 1.9.5 release with http2 and it worked fine, but Ajax request
> especially were problematic.
>
> I did get errors like:
> net::ERR_SPDY_COMPRESSION_ERROR
>
> And the status code was 0. With the former spdy support I didn't have any
> problems. I'm also using fastcgi and PHP5 in this server where I tried it.
> What could cause these problems?
>

Could you provide a debug log with problematic request?

http://nginx.org/en/docs/debugging_log.html

  wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 28 September 2015 at 19:44, Valentin V. Bartenev <[hidden email]> wrote:
On Wednesday 23 September 2015 06:28:37 Aapo Talvensaari wrote:
>> I did get errors like:
>> net::ERR_SPDY_COMPRESSION_ERROR
> Could you provide a debug log with problematic request?

I tried to debug this further. And now I'm closer to what happens.

If Ajax request sends a PUT request with XmlHtttpRequest I do get:
net::ERR_SPDY_COMPRESSION_ERROR

But this is only when the PHP-FPM reponds with error code:

<?php
header(':', true, 403);
die(json_encode(array( ... ))); 


Where that "..." is the array contents json_encoded. So it seems to be a problem with
HTTP error codes and HTTP2. On 200 return codes it works fine.

On logs, I do not get anything.


Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Valentin V. Bartenev-3
On Monday 28 September 2015 20:59:23 Aapo Talvensaari wrote:

> On 28 September 2015 at 19:44, Valentin V. Bartenev <[hidden email]> wrote:
>
> > On Wednesday 23 September 2015 06:28:37 Aapo Talvensaari wrote:
> > >> I did get errors like:
> > >> net::ERR_SPDY_COMPRESSION_ERROR
> > > Could you provide a debug log with problematic request?
> >
>
> I tried to debug this further. And now I'm closer to what happens.
>
> If Ajax request sends a PUT request with XmlHtttpRequest I do get:
> net::ERR_SPDY_COMPRESSION_ERROR
>
> But this is only when the PHP-FPM reponds with error code:
>
> <?php
> header(':', true, 403);
> die(json_encode(array( ... )));

What does ":" mean in the header() function?
If it returns ":" as a header, then it's the cause of the error.


>
>
> Where that "..." is the array contents json_encoded. So it seems to be a
> problem with
> HTTP error codes and HTTP2. On 200 return codes it works fine.
>
> On logs, I do not get anything.

There is no way to get nothing in the debug log
if it properly configured according to the article:
http://nginx.org/en/docs/debugging_log.html

 wbr, Valentin V. Bartenev


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 29 September 2015 at 00:01, Valentin V. Bartenev <[hidden email]> wrote:
>On Monday 28 September 2015 20:59:23 Aapo Talvensaari wrote:
>> On 28 September 2015 at 19:44, Valentin V. Bartenev <[hidden email]> wrote:
>> If Ajax request sends a PUT request with XmlHtttpRequest I do get:
>> net::ERR_SPDY_COMPRESSION_ERROR
>>
>> But this is only when the PHP-FPM reponds with error code:
>>
>> <?php
>> header(':', true, 403);
>> die(json_encode(array( ... )));
>
> What does ":" mean in the header() function?
> If it returns ":" as a header, then it's the cause of the error.

It just sets the status code. It is normal PHP 5.3 code [1]. I might need to compile nginx by hand to get more debug info. 


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 29 September 2015 at 01:06, Aapo Talvensaari <[hidden email]> wrote:
> On 29 September 2015 at 00:01, Valentin V. Bartenev <[hidden email]> wrote:
>> What does ":" mean in the header() function?
>> If it returns ":" as a header, then it's the cause of the error.
>>
> It just sets the status code. It is normal PHP 5.3 code.

I will test tomorrow to see if setting header differently makes any effect. But still it is puzzling to me that the same code worked fine with SPDY. So maybe SPDY had a more loose way of parsing headers? Shouldn't it be followed here as well, as the most browsers do that as well:  "Be conservative in what you send, be liberal in what you accept".

Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Francis Daly
In reply to this post by Aapo Talvensaari
On Tue, Sep 29, 2015 at 01:06:50AM +0300, Aapo Talvensaari wrote:
> On 29 September 2015 at 00:01, Valentin V. Bartenev <[hidden email]> wrote:
> > >On Monday 28 September 2015 20:59:23 Aapo Talvensaari wrote:
> > >> On 28 September 2015 at 19:44, Valentin V. Bartenev <[hidden email]>
> > wrote:

Hi there,

> > >> <?php
> > >> header(':', true, 403);
> > >> die(json_encode(array( ... )));
> > >
> > > What does ":" mean in the header() function?
> > > If it returns ":" as a header, then it's the cause of the error.
> >
> > It just sets the status code. It is normal PHP 5.3 code [1]. I might need
> to compile nginx by hand to get more debug info.

For what it's worth:

when I test with a php 5.1.6 and a php 5.3.3,

  header(':', true, 403);

sets the status code and adds a header called :.

So the end of the http header looks like

  X-Powered-By: PHP/5.3.3
  ::

with the debug log showing

  http fastcgi header: "X-Powered-By: PHP/5.3.3"
  http fastcgi parser: 0
  http fastcgi header: ":: "

Using

  header("HTTP/1.1 403 Whatever");

sets the status code and does not add the dubious header.

        f
--
Francis Daly        [hidden email]

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 29 September 2015 at 12:25, Francis Daly <[hidden email]> wrote:

> On Tue, Sep 29, 2015 at 01:06:50AM +0300, Aapo Talvensaari wrote:
> > It just sets the status code. It is normal PHP 5.3 code [1]. I might need
> > to compile nginx by hand to get more debug info.
>
> For what it's worth:
>
> when I test with a php 5.1.6 and a php 5.3.3,
>
>   header(':', true, 403);
>
> Using
>
>   header("HTTP/1.1 403 Whatever");
>
> sets the status code and does not add the dubious header.


Thanks. I know this is not probably a best way to set it (and in this case I can
change it, but it seems like this may cause some problems with user code.
See, the browsers accept it, the Nginx HTTP accepts it, Nginx HTTPS accepts
it, and even Nginx SPDY accepts it. Only Nginx HTTP/2 will not accept it. And
by accepting I mean, browsers and other Nginx protocols give the correct status
code as well.

Thanks for debugging this furher. I think everyone now has the knowledge of
what is going on.

Is this a bug or a feature? Because it might break user code running on Nginx,
I might call it a bug. Because it breaks only when these weird headers are in
place I might call it a feature.


Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Sergey Kandaurov
In reply to this post by Francis Daly
On Sep 29, 2015, at 12:25 PM, Francis Daly <[hidden email]> wrote:

> On Tue, Sep 29, 2015 at 01:06:50AM +0300, Aapo Talvensaari wrote:
>> On 29 September 2015 at 00:01, Valentin V. Bartenev <[hidden email]> wrote:
>>>> On Monday 28 September 2015 20:59:23 Aapo Talvensaari wrote:
>>>>>
>>>>> <?php
>>>>> header(':', true, 403);
>>>>> die(json_encode(array( ... )));
>>>>
>>>> What does ":" mean in the header() function?
>>>> If it returns ":" as a header, then it's the cause of the error.
>>>
>>> It just sets the status code. It is normal PHP 5.3 code [1]. I might need
>> to compile nginx by hand to get more debug info.
>
> For what it's worth:
>
> when I test with a php 5.1.6 and a php 5.3.3,
>
>  header(':', true, 403);
>
> sets the status code and adds a header called :.
>
> So the end of the http header looks like
>
>  X-Powered-By: PHP/5.3.3
>  ::
>
> with the debug log showing
>
>  http fastcgi header: "X-Powered-By: PHP/5.3.3"
>  http fastcgi parser: 0
>  http fastcgi header: ":: "

So, the header field name output as generated with php
(and previously guessed by Valentin),
is invalid as per 7230, which is in turn referenced in 7540.

:   field-name = token
:   token = 1*tchar
:   tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
:    "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA

Not much to discuss.

--
Sergey Kandaurov

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 29 September 2015 at 13:38, Sergey Kandaurov <[hidden email]> wrote:

> So, the header field name output as generated with php
> (and previously guessed by Valentin),
> is invalid as per 7230, which is in turn referenced in 7540.
>
> :   field-name = token
> :   token = 1*tchar
> :   tchar = "!" / "#" / "quot; / "%" / "&" / "'" / "*" / "+" / "-" / "." /
> :    "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
>
> Not much to discuss.

Even if it works just fine with every browser and every other protocol in Nginx than
HTTP/2? I kinda agree, but being in sense "be liberal what you accept, be
conservative on what you send", it may make the issue still a worth to solve.

Also it should be checked what happens here on the Nginx itself as this may even
be a possible bug. Why doesn't it reply with something like internal sever error or
something in that case? I mean, in worst case this might be a source for a security
bug (note: I'm not saying it is).

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Valentin V. Bartenev-3
On Tuesday 29 September 2015 14:14:44 Aapo Talvensaari wrote:

> On 29 September 2015 at 13:38, Sergey Kandaurov <[hidden email]> wrote:
> > So, the header field name output as generated with php
> > (and previously guessed by Valentin),
> > is invalid as per 7230, which is in turn referenced in 7540.
> >
> > :   field-name = token
> > :   token = 1*tchar
> > :   tchar = "!" / "#" / "quot; / "%" / "&" / "'" / "*" / "+" / "-" / "." /
> > :    "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
> >
> > Not much to discuss.
>
> Even if it works just fine with every browser and every other protocol in
> Nginx than
> HTTP/2? I kinda agree, but being in sense "be liberal what you accept, be
> conservative on what you send", it may make the issue still a worth to
> solve.
>
> Also it should be checked what happens here on the Nginx itself as this may even
> be a possible bug. Why doesn't it reply with something like internal sever
> error or something in that case? I mean, in worst case this might be a source for a security  bug (note: I'm not saying it is).

NGINX doesn't reply anything special about this header in HTTP/2.
The behavior you see is on the client side.

  wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Valentin V. Bartenev-3
In reply to this post by Aapo Talvensaari
On Tuesday 29 September 2015 13:34:46 Aapo Talvensaari wrote:

> On 29 September 2015 at 12:25, Francis Daly <[hidden email]> wrote:
> > On Tue, Sep 29, 2015 at 01:06:50AM +0300, Aapo Talvensaari wrote:
> > > It just sets the status code. It is normal PHP 5.3 code [1]. I might need
> > > to compile nginx by hand to get more debug info.
> >
> > For what it's worth:
> >
> > when I test with a php 5.1.6 and a php 5.3.3,
> >
> >   header(':', true, 403);
> >
> > Using
> >
> >   header("HTTP/1.1 403 Whatever");
> >
> > sets the status code and does not add the dubious header.
>
>
> Thanks. I know this is not probably a best way to set it (and in this case
> I can change it, but it seems like this may cause some problems with user code.
> See, the browsers accept it, the Nginx HTTP accepts it, Nginx HTTPS accepts
> it, and even Nginx SPDY accepts it. Only Nginx HTTP/2 will not accept it.

The error that you have seen isn't from NGINX, it's generated by browser.
The behavior of NGINX is consistent across all protocols, but the reaction
of specific browser, that you have tested, seems not.

> And by accepting I mean, browsers and other Nginx protocols give the correct
> status code as well.

It's not about the status code.  Note, that the function you are calling in PHP
does two things: 1. sets the status code; 2. adds invalid header.

The 1 and 2 aren't related to each other.
 
>
> Thanks for debugging this furher. I think everyone now has the knowledge of
> what is going on.
>
> Is this a bug or a feature?

Yes, it's a bug. But it's in the application that generates invalid response.
The result of such invalid response is undefined - may work or may not, depending
on client's behavior.  NGINX tolerates it, some browsers do not.

> Because it might break user code running on
> Nginx, I might call it a bug.

The code was already broken, it was a coincidence that it worked.

  wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
On 30 September 2015 at 02:20, Valentin V. Bartenev <[hidden email]> wrote:
> The code was already broken, it was a coincidence that it worked.

Thanks for the patience. Case closed. I just wanted to be sure. It seems like Chrome is more demanding on HTTP/2 headers than others.

Regards
Aapo

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Problems with HTTP/2

Aapo Talvensaari
> On 30 September 2015 at 02:20, Valentin V. Bartenev <[hidden email]> wrote:
> The code was already broken, it was a coincidence that it worked.

I can now confirm that fixing code fixed the issue. Thank you. HTTP/2 works like a charm!

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx