Skip to content

Reject websocket extensions? #1508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SoylentGraham opened this issue Feb 17, 2021 · 3 comments
Closed

Reject websocket extensions? #1508

SoylentGraham opened this issue Feb 17, 2021 · 3 comments

Comments

@SoylentGraham
Copy link

I'm currently routing websocket connections via http-proxy to my own c++ websocket app.
When I send large text frames from my client (chrome), I'm getting some odd opcodes, reserved bits set etc, which I don't recognise, so I kick the client(proxy) from my server (app)

After some debugging, I believe these are opcodes from deflate extensions (still figuring it out).
I don't ever get this problem when I connect directly to my app/websocket code (sending huge frames without missing a beat)

I think the proxy is accepting the deflate extension, although I reject it, and I'm getting deflate-compressed packets(hence the opcodes)

I have 2 questions

  1. Is it possible http-proxy ignores my websocket's handshake responses, perhaps to establish a handshake ASAP
  2. If so, can I explicitly reject these? (Overriding the handshake in node, seems doable)

Maybe I've overlooked some specific documentation over this, or searched issues for the wrong terms.

@SoylentGraham
Copy link
Author

#882 might cover this

@SoylentGraham
Copy link
Author

I think this does it, but not sure, (certainly sends blank extensions to my websocket), seems to be hard to get the details of the response in chrome dev tools

function OnProxyWebsocketRequest(proxyReq, req, socket, options, head) 
{
	console.log(`OnProxyWebsocketRequest; ${JSON.stringify(proxyReq,null,'\t')}`);
	proxyReq.setHeader('Sec-WebSocket-Extensions','');
};
const Proxy = httpProxy.createProxyServer(ProxyOptions);
Proxy.on('proxyReqWs',OnProxyWebsocketRequest);

@SoylentGraham
Copy link
Author

Was a bug with large packets (I ended up decoding the header twice, but had already eaten header data) in my websocket implementation
NewChromantics/SoyLib@6cce808#diff-25a6634263c1b1f6fc4697a04e2b9904ea4b042a89af59dc93ec1f5d44848a26

I think the above code does still do what I want, but it would be good to know if the proxy does propogate my header changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant