adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 125 forks source link

websocket and fastcgi issue #301

Closed o3o closed 2 years ago

o3o commented 2 years ago

I am testing your awesome cgi and websocket modules see here.

I need to use both cgi and websocket, but when I add in dub

subConfiguration "arsd-official:cgi" "fastcgi"

my server example crashes. If I remove subConfiguration it works well

My env.

uname -a                                                                                                                                             
Linux abe 5.13.13-arch1-1 #1 SMP PREEMPT Thu, 26 Aug 2021 19:14:36 +0000 x86_64 GNU/Linux

dmd --version                                                                                                                                 
DMD64 D Compiler v2.097.2

Thank you.

adamdruppe commented 2 years ago

Websockets and cgi don't mix very well by default because with websocket you want to take control of the connection, but with cgi, the connection is managed by the parent web server.

So the websocket server tries to take ownership of the connection and send non-http data, but the outer server has no idea and tries to close it despite you still using it, or intercepts the Upgrade header, or just plain thinks the datastream is corrupted.

I tried to make the cgi.d add-on server for websocket to work around this, but it always had some kind of conflict anyway and just wasn't reliable.

You might be able to configure your outer http server (apache or nginx or whatever) to allow it, but as far as I know cgi+websocket is unsupported by them.

But you're best off using one of the embedded httpd modes in cgi.d and using your outer server as a reverse proxy.

o3o commented 2 years ago

exhaustive as always ... Thank you very much for your support