Only receiving the first character of incoming messages

Open
#288 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
networking

Research direction

Reproduce the issue with the Laputa code sample from the README under Mono 4.4, using WebSocketServer and the OnMessage handler as the entry points. Trace incoming message delivery and verify that sending “BALUS” produces the complete value in e.Data rather than only “B”; the issue is done when the sample responds correctly.

Written by the indexing model from the issue text.

Description

This is bizarre. I've installed via nuget, and then I cloned and built from source. I'm running on mono 4.4. I can reproduce the behavior with the Laputa code sample from the README. Opening the socket works fine. But when I try and actually send any data, I only receive the first character. So, here is (slightly modified) laputa sample I'm working against:

using System;
using WebSocketSharp;
using WebSocketSharp.Server;

namespace Example
{
    public class Laputa : WebSocketBehavior
    {
        protected override void OnMessage(MessageEventArgs e)
        {
            var msg = e.Data == "BALUS"
                ? "I've been balused already..."
                : "I'm not available now.";

            Send(msg);
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            var wssv = new WebSocketServer("ws://localhost:8003");
            wssv.AddWebSocketService<Laputa>("/Laputa");
            wssv.Start();
            while(true) {
                System.Threading.Thread.Sleep (1000);
            }
            //Console.ReadKey(true);
            wssv.Stop();
        }
    }
}

If I put a breakpoint in the OnMessage handler, e.Data is always just the first character. So if I send 'BALUS' as my message, I only get 'B' in e.Data, so the example fails to load.

Any ideas?

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

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.

More from sta/websocket-sharp

All issues in sta/websocket-sharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.