How to close a PSGI connection without an answer?

My application wants to pass a handle $env->{'psgix.io'}to separate the process for further WebSocket processing. Pass through the UNIX descriptor socket dup(), so I don’t need to return any response from the application to the PSGI server. But I do not see the possibility of just closing the connection without returning any response from the application. When I return nothing, the PSGI server is unhappy and registers a "500 Internal Server Error". When I return only a link to the code, for example sub {}, then Twiggy is happy, but uWSGI is not. Any other valid PSGI response violates the WebSocket protocol.

I tried to execute dup()raw handle and return the last part of the WebSocket handshake as a PSGI response, it worked with uWSGI but not with Twiggy.

I looked at various implementation of PSGI / WebSocket and made one of them:

  • do not return from the handler until the WebSocket is closed;
  • returns some sub {}.

What is the correct way to return a response and silently close the connection in the PSGI protocol?

UPDATE: Looks like Twiggy is using []PSGI as a cancellation message. My patch for uwsgi, to do the same, was successfully combined.

+4
source share

Source: https://habr.com/ru/post/1651759/


All Articles