I have website with plugin that send http requests and I am writing simple http server, so I could receive that requests. Unfortunatelly my server work properly only when i use firefox, but when i use chrome or edge, my server ignores requests. Server doesn't send errors and doesn't throw any exceptions, but act as there wasn't any request. What's more interesting my server have impact on my website and when i have running server my website get instant error, but when i haven't running server my website tries to connect and the error appears later.
I also tried run Fiddler Everywhere (web proxy that monitor http transmission) to see where is a problem, unexpectedly then my server start receiving request even from Chrome/Edge.
My code:
using System.Net;
namespace HttpListenerNamespace
{
class HttpServer
{
public static HttpListener listener;
public static string url = "http://localhost:3050/";
public static async Task HandleIncomingConnections()
{
bool runServer = true;
while (runServer)
{
Console.WriteLine("Waiting for signal");
HttpListenerContext ctx = await listener.GetContextAsync();
Console.WriteLine("Request received");
}
}
public static void Main(string[] args)
{
listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
Task listenTask = HandleIncomingConnections();
listenTask.GetAwaiter().GetResult();
listener.Close();
}
}
}
Output:
When I run my server and send request from my firefox website:
Waiting for signal
Request received
Waiting for signal
When I send request from the same website, but in Chrome/Edge:
Waiting for signal