user1699322
user1699322

Reputation: 31

How to close websocket-connection manually in Cowboy-server?

How can I close a websocket connection manually (from server side) in Cowboy-server? I would check login/password in callback-module in init/3 and kick "wrong" users with some return code. What is the best way to do this?

Upvotes: 3

Views: 1110

Answers (1)

Sergey Miryanov
Sergey Miryanov

Reputation: 1830

Try to return {shutdown, Req, State} from your handler:

https://github.com/extend/cowboy/blob/master/src/cowboy_websocket_handler.erl

Upvotes: 1

Related Questions