Skip to content

Deny HTTP requests (ws only server) #1872

Answered by carltongibson
realsuayip asked this question in Q&A
Discussion options

You must be logged in to vote

Ideally your load-balancer (nginx for example) correctly routes the different request types to the correct app.

You could though define an http handler in a ProtocolTypeRouter in order to reject any HTTP requests that did arrive.

As of v3 ProtocolTypeRouter defines a default http handler if you don't provide one, but will not do that from v4 (next main version) — so HTTP requests would result in a ValueError, that would get converted to 500 — so you might want to define a dummy 4xx type handler if you think such requests may arrive at your application.

I hope that helps.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@realsuayip
Comment options

Answer selected by realsuayip
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants