websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

HTTP-Server not working properly

Open dominik4545 opened this issue 6 years ago • 3 comments

Hi all,

I am using the latest NuGet-package (WebSocketSharp 1.0.3-rc11) and want to use the HttpServer to control the websocket-services via HTTP-requests (e.g. provide the status via GET-request).

Unfortunately the HttpServer does not work as described in your example. First of all the method WriteContent which was used in Example 3 is neither available in the master branch nor in the NuGet-package.

After some investigation I found the possibility to use the OutputStream-property which is provided by the HttpListenerResponse to potentially send data back to the calling browser/client or the function Close() doing the same. Both methods were displayed with the error "Empty message received" in the browser.

Do you know about this issue? My code is the following:

HttpServer srv = new HttpServer(IPAddress.Any, 9210);
srv.Log.Output = (data, s) => { Debug.WriteLine(data); };
srv.OnGet += (s, e) => {
       e.Response.Close(Encoding.UTF8.GetBytes("Hello World!"), true);
};
srv.Start();

dominik4545 avatar Jul 10 '19 08:07 dominik4545

What source

JuneTwooo avatar Jul 18 '19 08:07 JuneTwooo

I have the same problem when I have built from source code. I downloaded last version and trying to run. On windows all works good. On linux just getting empty response. Tried on Ubuntu 18.04, centos 8, Ubuntu 16. With different combinations of mono 6.1.x and 5.20.

Also tried to run Example3 from the repository. Same problem.

Could someone help?

robertsabo0 avatar May 18 '20 07:05 robertsabo0

Ok, i fixed it. The problem was with some additional files in running folder. I had a copy from windows. Even with new build overwrite, it was not working. After 3 days of trying, I found that it works when I deploy to empty folder. By deleting additional files from old folder, it started to work correctly.

Looks like some .dll files made it do not work correct.

Can someone explain how could that happen?

robertsabo0 avatar May 19 '20 07:05 robertsabo0