Skip to content

Support default port for known schemas#1478

Open
DavidJohnWilliams wants to merge 2 commits into
wiremock:masterfrom
DavidJohnWilliams:1477-default-ports
Open

Support default port for known schemas#1478
DavidJohnWilliams wants to merge 2 commits into
wiremock:masterfrom
DavidJohnWilliams:1477-default-ports

Conversation

@DavidJohnWilliams

Copy link
Copy Markdown
  • Update tests which expected urls without port to fail
  • Add new tests for default ports

References

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

- Update tests which expected urls without port to fail
- Add new tests for default ports
@StefH StefH added the feature label Jun 26, 2026
@StefH StefH self-requested a review June 26, 2026 12:32
public void PortUtils_TryExtract_DefaultPort_Https_Returns_True()
{
// Assign
var url = "https://0.0.0.0";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if you can also add a "real" unit test which starts wiremock at https;//0.0.0.0 or https://localhost with that port?

Like this:
https://github.com/wiremock/WireMock.Net/blob/master/test/WireMock.Net.Tests/WireMockServerTests.cs#L199

(it could be that that test runs locally correct, and maybe in CI-CD fails, maybe, we have to see)

@DavidJohnWilliams

Copy link
Copy Markdown
Author

@StefH I tried adding a test as you suggested and it fails I believe because the port is already in use.

I guess something to do with running as a hosted service under IIS vs running in a unit test context.

It's essentially calling the same code WireMockServer.Start but I'm guessing there is a lot going on under the hood that I don't know about.

@StefH

StefH commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

I guess you test locally in Windows?


If you create a simple console-app, and use that setup, does it also fail?

@StefH

StefH commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@DavidJohnWilliams
If you create a simple console-app, and use that setup, does it also fail?


And if this keeps failing, then I my assumption is that providing a port is mandatory and does make sense. So in that case, no change in the code is needed, only updating the docs is required. Agree?

@DavidJohnWilliams

Copy link
Copy Markdown
Author

Hi, sorry for the delay. I tried creating a console app. It actually fails whether I include a port or not.

For background we are hosting our instance of WireMock in IIS under "https://customdomain.local" which is configured with port 443 and a certificate.

In the console app, I tried:

  • Custom URL no port -> Socket error
  • Custom URL with port 443 -> Socket error
  • Custom URL with random port -> Works fine

However when hosting under IIS both of the first two options work.

As I said before, I think if the docs are clear that a port is required, then I am happy with that. I mostly raised this because it was a breaking change for us. We had been running without a port specified, and didn't see anything in the changelog or docs about requiring one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants