Skip to content
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

Enhanced WebSocket Protocol Handling in Proxy Server Connections #304

Merged
merged 1 commit into from
Mar 1, 2024
Merged

Enhanced WebSocket Protocol Handling in Proxy Server Connections #304

merged 1 commit into from
Mar 1, 2024

Conversation

sweet-peach
Copy link
Contributor

Problem:
Previously, the proxy server's handling of WebSocket connections overlooked the sec-websocket-protocol header, which is critical for specifying subprotocols. For example, when a client requested to establish a WebSocket connection with a specific protocol (e.g., json.reliable.webpubsub.azure.v1 for chatgpt), the proxy would initiate the connection without passing along the requested protocol. This oversight could lead to connection failures or incorrect server behaviors, as the server might not respond with the necessary connection message if the expected protocol was not specified. An example of this issue was observed on the "chatgpt" page, where omitting the protocol led to malfunctioning due to the server's expectation for a specific subprotocol to establish a WebSocket connection.

Solution:
The modifications entail capturing the protocol specifications from client requests and incorporating these details into the connection options. Subsequently, these options are passed to the WebSocket constructor, thereby ensuring that the connection process is fully compliant with the protocol requirements.

In the previous implementation, when a client sends a proxy specification with the sec-websocket-protocol protocol, the proxy would disregard it and establish a connection to the server without this specification. This could lead to an incorrect connection and ultimately result in data not being sent. In my commit, I've modified the code to include the utilized protocols in the options and then pass them to the WebSocket constructor, ensuring the protocol specification is honored during the connection process
@joeferner joeferner merged commit ad79ddc into joeferner:master Mar 1, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

2 participants