Logging

Is it possible to log websocket requests in nginx access log ? Or is
this
logging restricted only to http requests ?
tammini

Posted at Nginx Forum:

Hello!

On Wed, Jan 06, 2016 at 09:11:54AM -0500, tammini wrote:

Is it possible to log websocket requests in nginx access log ? Or is this
logging restricted only to http requests ?

WebSocket requests are no different from other HTTP requests -
they just establish a WebSocket connection using the Upgrade HTTP
mechanism. They are logged to access logs much like other HTTP
requests once the WebSocket connection is closed.

Note though that it’s not possible to log what happens inside a
WebSocket connection.


Maxim D.
http://nginx.org/

Does that mean once a websocket connection is opened successfully, any
subsequent requests sent on that connection cannot be logged ?

Thanks.

Posted at Nginx Forum:

Only time you see a log for a web socket connection is when it get
disconnected. So you will not see a log when it connects, transfer data
over it.

On Mon, Jan 11, 2016 at 8:21 PM, tammini [email protected]

Hello!

On Mon, Jan 11, 2016 at 11:21:35PM -0500, tammini wrote:

Does that mean once a websocket connection is opened successfully, any
subsequent requests sent on that connection cannot be logged ?

No HTTP requests can be sent into a connection which was upgraded
to a WebSocket connection. It’s a one way operation. Anything
inside a websocket connection happens more or less as a body of
the HTTP request (and the response).

(Note well that there are no requests inside WebSocket connections.
WebSockets use frames to ensure data delivery, and doesn’t specify
anything else. And, as previously said, nginx doesn’t try to parse
and/or log anything inside WebSocket connections.)


Maxim D.
http://nginx.org/