Browser and Server Communication Problem - Server only receive One text?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp, unity
- Domain
- networking
Research direction
Reproduce the report with the EchoTest client and IOWebSocket/Echo server code, comparing standalone Unity and Firefox HTML5 builds. Start by tracing the WebSocket connection and message loop; done means identifying why only the first message arrives and verifying the behavior after the correction.
Written by the indexing model from the issue text.
Description
I try to build the website and communicate with Server (not web server), by using unity3D.
The problem is that, when i run both code on unity3d (one is client, other one Server). Both can send/ receive test string very well.
[client side will send text:0,1,2,3,4,5,....][client side receive text:123,123]
[server side will send test:123,123. if server receive client side data][server side receive text:0,1,2,3,4,5,....]
But when i build the [website(client) code] to html5 by using unity3D and run on Firefox browser. The server only receive One text data.
[server side receive the text:0]
[client side no receive]
This is website(client) code:
public class EchoTest : MonoBehaviour {
// Use this for initialization
IEnumerator Start () {
WebSocket w = new WebSocket(new Uri("ws://127.0.0.1:3000"));
yield return StartCoroutine(w.Connect());
w.SendString("0");
int i = 0;
while (true)
{
string reply = w.RecvString();
if (reply != null)
{
Debug.Log ("Received: "+reply);
w.SendString(""+i++);
}
if (w.error != null)
{
Debug.LogError ("Error: "+w.error);
break;
}
yield return 0;
}
w.Close();
}
}
This is Server code:
public class IOWebSocket : MonoBehaviour
{
private static int i = 0;
WebSocketServer server;
void Start()
{
server = new WebSocketServer(3000);
server.AddWebSocketService<Echo>("/");
server.Start();
}
void OnDestroy()
{
server.Stop();
server = null;
}
}
// Update is called once per frame
public class Echo : WebSocketBehavior
{
protected override void OnMessage(MessageEventArgs e)
{
Sessions.Broadcast("123");
Debug.Log(System.Text.Encoding.Default.GetString(e.RawData));
}
}
I need some help,plz
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sta/websocket-sharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sta/websocket-sharp#201 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
sta/websocket-sharp#762 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
sta/websocket-sharp#761 ·
-
Bad handling of sending stream makes lib not RFC compatible and KeepClean useless in some cases. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
sta/websocket-sharp#760 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sta/websocket-sharp#759 ·
All issues in sta/websocket-sharp
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·