Forum: NGINX Would like to implement WebSocket support

Posted by "André Caron" <andre.l.caron@gmail.com> (Guest)
on 2012-02-02 04:55
(Received via mailing list)
 Hi all!

I've implemented the WebSocket wire protocol as an incremental parser, 
making it
suitable for use in high-end asynchronous servers such as NGINX.  The 
code is
open source (BSD-licenced) and available on GitHub[1].  I plan on using 
it to
tunnel other protocols (svn and git, in particular) over HTTP.  I have a 
nice
setup that works well on the client side, but I'd like to integrate this 
with my
existing NGINX stack with includes virtual hosting and a bunch of other 
stuff (I
can't use another server directly unless I use a non-default port).

To the best of my understanding, NGINX has no support for WebSockets. 
The HTTP
proxy module does not support HTTP 1.1 and WebSockets are incompatible 
with both
SCGI and FastCGI because of the "Content-Length" problem (it is assumed 
to be 0
if unspecified).

I'd like to implement an NGINX module that specifically handles 
WebSockets so
that I can integrate my tunnel in my NGINX setup. I have absolutely no
experience with the NGINX source code, but  I've found a nice guide on 
writing
NGINX modules[2].  After initial reading, I understand that I need to 
write an
Upstream (proxy) handler.  Is this correct?

The HTTP proxy module has a scary note that says:

> Note that when using the HTTP Proxy Module (or even when using FastCGI), the
  entire client request will be buffered in nginx before being passed on 
to the
  backend proxied servers.

Is this a limitation cause by NGINX's architecture, or is this by design
(e.g. for validation of body against headers, etc.)?

The bigger problem, however, is that there is no standard interface to
application servers for this new WebSocket protocol.  There is some
discussion[3] on an Apache enhancement request that basically proposes a
modification of CGI.  Since CGI has already been demonstrated to be a
performance problem, I'm looking for an alternate solution, maybe 
something
closer to SCGI?  Anyone have suggestions?

Thanks, André

[1]: https://github.com/AndreLouisCaron/cwebs
[2]: http://www.evanmiller.org/nginx-modules-guide.html [3]:
https://issues.apache.org/bugzilla/show_bug.cgi?id=47485#c13
Posted by Shaun Savage (Guest)
on 2012-02-02 15:35
(Received via mailing list)
I have been looking for websockets support.  I have written a server
push back end for nginx using the "keep-alive" module. I have one
persistent connection for the server push. this connection is an async
client control. then each new "command/request" from the client is a new
http connection.  I use fcgi, because fcgi also requires a "length" a
single connection is not possible.

websockets would make make my life easier( and faster). with websockets
support nginx would become the defacto standard for web applications.

because of client/browser security using another port for websockets is
undesirable.

I am not a nginx expert but I assume that the buffering the full request
is a performance issue.

i hope to hear more about websockets
Posted by Alexandr Gomoliako (Guest)
on 2012-02-02 18:37
(Received via mailing list)
On 2/2/12, Andr Caron <andre.l.caron@gmail.com> wrote:

> NGINX modules[2].  After initial reading, I understand that I need to write
> an Upstream (proxy) handler.  Is this correct?

Not really.

> The HTTP proxy module has a scary note that says:
>
>> Note that when using the HTTP Proxy Module (or even when using FastCGI),
>> the entire client request will be buffered in nginx before being passed on to
>> the backend proxied servers.
>
> Is this a limitation cause by NGINX's architecture, or is this by design
> (e.g. for validation of body against headers, etc.)?

It just means that you can't use existing upstream modules and
upstream interface.

> The bigger problem, however, is that there is no standard interface to
> application servers for this new WebSocket protocol.  There is some
> discussion[3] on an Apache enhancement request that basically proposes a
> modification of CGI.  Since CGI has already been demonstrated to be a
> performance problem, I'm looking for an alternate solution, maybe something
> closer to SCGI?  Anyone have suggestions?

I think what you need here is a simple protocol upgrade functionality
that switches to tcp proxying for particular connection once it
encounters upgrade in connection header. And everything else is up to
application server.
So you don't really need to parse websocket protocol in nginx unless
it is your application server.
Posted by crazedfred (Guest)
on 2012-02-29 20:31
(Received via mailing list)
Alexandr Gomoliako Wrote:
-------------------------------------------------------
> says:
> etc.)?
> that basically proposes a
> encounters upgrade in connection header. And
> everything else is up to
> application server.
> So you don't really need to parse websocket
> protocol in nginx unless
> it is your application server.
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


Any progress on this?
I would be very interested in a plugin that brings websocket support.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,221884,223186#msg-223186
Posted by cyberchris (Guest)
on 2012-05-18 11:15
(Received via mailing list)
Hello,
I want to use websockets in my appliaction server. My provider has
always in front of the application server an nginx-server.
And since nginx currently doesn't support websockets I have a problem.
So I just wanted to ask, how is the progress about proxiing websocket
communications?
I would be very great and I could imagine that other users may ask for
that, too in the near future.

Thank you,
Chris

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,221884,226622#msg-226622
Posted by Alexandr Gomoliako (Guest)
on 2012-05-18 16:15
(Received via mailing list)
> I want to use websockets in my appliaction server. My provider has
> always in front of the application server an nginx-server.
> And since nginx currently doesn't support websockets I have a problem.
> So I just wanted to ask, how is the progress about proxiing websocket
> communications?
> I would be very great and I could imagine that other users may ask for
> that, too in the near future.

I've been playing with websockets for awhile now and I don't think it
can make a difference for your provider. Real time web application are
really expensive to handle, each frame costs almost as much as
keepalive request, but you don't usually expect hundreds of requests
from each client every second. It's like streaming video by 100 bytes
at a time.

So, it has to be some kind of frame multiplexing over a single
connection with backend and even then it's still a lot to handle.
Posted by "姚伟斌" <nbubingo@gmail.com> (Guest)
on 2012-05-21 04:47
(Received via mailing list)
This feature will be implement in the 1.3 branch, you can see the
roadmap here: http://trac.nginx.org/nginx/roadmap

Or you can use my tcp proxy module as an alternative temporarily :
https://github.com/yaoweibin/nginx_tcp_proxy_module

Thanks.

2012/5/18 Alexandr Gomoliako <zzz@zzz.org.ua>:
Posted by zestsh (Guest)
on 2012-06-04 08:32
(Received via mailing list)
is there some discussing about the future websocket implementation?

from the roadmap, we couldn't get to know any new information.

Thank you.

姚伟斌 Wrote:
-------------------------------------------------------
>
> >> I would be very great and I could imagine that
> hundreds of requests
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,221884,227134#msg-227134
Posted by zestsh (Guest)
on 2012-06-04 10:33
(Received via mailing list)
will the websocket implementation in the nginx 1.3 branch work same with
the tcp_proxy_module?

if not, what will be it look like? I hope nginx developer geeks give
some clues
about functionality or related api provided.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,221884,227140#msg-227140
Posted by zestsh (Guest)
on 2013-03-16 04:20
(Received via mailing list)
Finally, Nginx 1.3.13 supports websocket officially.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,221884,237425#msg-237425
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.