sta / sta/websocket-sharp

HTTP-Server not working properly

Open
#551 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

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();

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example using Example3/Program.cs and inspect websocket-sharp/Net/HttpListenerResponse.cs, especially WriteContent, OutputStream, and Close(). Compare the documented example with the 1.0.3-rc11 behavior and determine why the client receives an empty message; done means the HTTP GET returns the intended response consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.