cowboy icon indicating copy to clipboard operation
cowboy copied to clipboard

Question - Not possible to keep a connection state?

Open JeppeTh opened this issue 4 years ago • 3 comments

Hi!

I can't find any way to neither be informed about new connections - nor any possibility to update the initial state of a path handler. Is there no way to achieve any of this? If things are needed to be done once per connection (without process jump for each request)? Also we want to set DSCP for each connection - but at the same time be able to update the DSCP without restarting connections.

Is the only way currently to keep this externally e.g. an ets-table? Or wrap...

And for this we really need to be informed about when a connection is lost as well...

JeppeTh avatar Dec 13 '20 14:12 JeppeTh

You can probably write a custom Ranch protocol that then defers to Cowboy's and do any modification you require there. For connection loss the process will exit so monitoring is probably the way to go.

For updating existing connections I don't think there's currently a built-in way to do this. On the other hand you can have your custom Ranch protocol pass the socket forward via the options and then write a stream handler that will process an arbitrary message to update the socket options.

essen avatar Dec 13 '20 14:12 essen

Ok - thx. I assume custom protocol means wrapping cowboy:start as well then?

JeppeTh avatar Dec 13 '20 14:12 JeppeTh

Just using ranch:start_listener directly.

essen avatar Dec 13 '20 14:12 essen