Hello all, I'm trying to get WireMock for .NET St...
# help
b
Hello all, I'm trying to get WireMock for .NET Standalone working within docker. Is this possible? I'm following the example from Option 3 here: https://wiremock.org/dotnet/wiremock-as-a-standalone-process/#option-3--coding-yourself If I use that example as written, then it gets stuck in a crash loop due to Console.ReadKey(). If I remove Console.ReadKey() or replace with Console.Read() then the program just runs once, then restarts, never being reachable. If I try adding in the following:
Copy code
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
await app.RunAsync();
Then it does stay up, but Wiremock isn't reachable. If I try hitting it, it just returns a 404. Any advice would be appreciated.
m
About your first problem, the
Console.ReadKey()
, this is probably crashing because you're starting your docker container without a tty attached. It should work if you run your container with
-it
. This will assign a tty to it and attach interactively. With that, the example should run as is. Perhaps you could try that first. If it still doesn't work, then it would be indicative of a different problem, but that'll give some clue at least
b
Thanks for the advice. I'll try that.
I ran it with
-it
and it did start up and stay up, but when I try hitting one of my URLs it just returns an empty response. There is nothing in the logs except the startup message.
m
In that case, before even running it in docker, can you run your code directly on your computer and see if it works? That'll allow you to run a debugger too
If you have a public repo I can clone, and one that I could run on macOS, I could take a quick look too
b
Everything works just fine when I run it in the Visual Studio debugger. The problems only occur in docker. I don't have a public repo, but I could look into making one tomorrow.
m
If everything works locally, it could be some docker networking issue. That's the only thing I can think of right now. If you could make a small reproducible case, I could try looking at it.
b
Got it working. Problem was external ports vs internal ports in docker. I had Wiremock listening for the external port, not the internal one. Once Wiremock was listening for the right port (internal), it all worked. Thanks again for all the help.
🙇 1
m
Glad you got it resolved!