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

Add port validation checks for HTTP streaming #315

Merged
merged 7 commits into from
Jan 21, 2025

Conversation

hallvictoria
Copy link
Contributor

@hallvictoria hallvictoria commented Nov 14, 2024

For HTTP streaming, the port is selected by the platform. However, there was no logic that checks if the selected port is valid and available. In the case where the OS is Windows and VNET integration is enabled, the platform defaults to port 0. Port 0 isn't valid, so any proxy requests fail, and the function execution times out.

This fix adds validation on the selected port value. If the port value is 0, the worker will search for and bind to an available port. It first starts searching at port 55000, and if that port isn't available, it will pick a random port between 55000 and 55025 (max port value) and search again. It continues this process until a port is found or throws an error if none are found.

There are no behavioral changes if the selected port value is not 0. The only scenario this change affects then is for Windows + VNET integration enabled.

@hallvictoria hallvictoria marked this pull request as ready for review November 14, 2024 20:08
@hallvictoria hallvictoria requested a review from a team as a code owner November 14, 2024 20:08
@gavin-aguiar gavin-aguiar merged commit dd5912c into v4.x Jan 21, 2025
12 checks passed
@gavin-aguiar gavin-aguiar deleted the hallvictoria/streaming-ports branch January 21, 2025 23:00
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