sta / sta/websocket-sharp

Socket opens then immediately closes

Open
#485 2 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

I am trying to use websocket-sharp to interface with a pro-presenter instance as a windows form app. i was able to get a similar project working with JavaScript. My .net version connects to the socket and runs the OnOpen event then immediately runs the OnClose event. Below is my code block. Where am i going wrong?

         using (WebSocket ws = new WebSocket("ws://" + config.ComputerIP + ":" + config.Port + "/stagedisplay"))
        {
            ws.OnOpen += (sender, e) =>
            {
                // send connect string
                ws.Send("{\"pwd\":\"" + config.Password + "\",\"ptl\":610,\"acn\":\"ath\"}");
            };
            ws.OnMessage += (sender, e) =>
            {
                    slide.ProcessMessage(e.Data);
                    CurrentSlideLbl.Text = slide.CurrentSlide;
            };
            ws.OnClose += (sender, e) =>
                CurrentSlideLbl.Text = "reason:" + e.Reason;
            
            ws.OnError += (sender, e) =>
                CurrentSlideLbl.Text = "Socket encountered error: Closing socket" + e.Message;
            
            ws.Connect();
        }

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

Start with the WebSocket construction, event handlers, and ws.Connect() call shown in the issue, then inspect the OnClose and OnError values. Reproduce the connection against the stated ProPresenter endpoint and determine why it closes immediately; done means the cause is identified and a reliable connection behavior is demonstrated.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.