immediate disconnect in WebPlayer
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
I'm able to connect to a websocket server with this plugin. Inside the OnOpen callback, I send a message, and it's received by the server. ,
- If running in the webplayer, the socket disconnects immediately thereafter!
- In the editor, the websocket persists (as it should).
Here's a minimal test-case:
using System;
using UnityEngine;
using System.Collections;
using WebSocketSharp;
using WebSocketSharp.Net;
public class wstest : MonoBehaviour {
string address = "ws://192.168.1.223:9000/";
WebSocket webSocket;
void Start () {
Debug.Log("starting " + address);
Security.PrefetchSocketPolicy("192.168.1.223", 843, 3000);
webSocket = new WebSocket(address);
webSocket.OnOpen += OnOpen;
webSocket.OnMessage += OnMessageReceived;
webSocket.OnClose += OnClose;
webSocket.OnError += OnError;
webSocket.Connect();
}
// Update is called once per frame
void Update () {
}
void OnOpen(object sender, System.EventArgs e) {
webSocket.Send("hello");
}
void OnMessageReceived(object sender, MessageEventArgs e)
{
}
void OnClose(object sender, CloseEventArgs e)
{
}
void OnError(object sender, ErrorEventArgs e)
{
}
}
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.
Research direction
Start with the minimal Unity test case in the issue and compare the WebPlayer and editor connection lifecycles around OnOpen and Send. Reproduce the immediate disconnect, inspect the WebSocket connection and callback behavior used by the sample, and verify that the socket remains connected in WebPlayer after the message is sent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100