WWW can not get response on WegGL player mode

i made a webgl project. and i use HttpListerner(c#) as my server and use port 8081.
code like this:

 sSocket = ar.AsyncState as HttpListener;
                HttpListenerContext context = sSocket.EndGetContext(ar);
                sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), sSocket);
                HttpListenerRequest request = context.Request;
                HttpListenerResponse response = context.Response;
                Stream strem = request.InputStream;
                StreamReader reader = new StreamReader(strem, Encoding.UTF8);

                string info = reader.ReadToEnd();
                info = System.Web.HttpUtility.UrlDecode(info);
                reader.Close();
                strem.Close();

                string res = procCls.onProcInfo(info);

                byte[] buffer = Encoding.UTF8.GetBytes(res);
                response.ContentLength64 = buffer.Length;
                Stream output = response.OutputStream;
                output.Write(buffer, 0, buffer.Length);
                output.Close();
                response.Close();

the function are save document data and so on. when i play in editor mode, it run ok. i can send message to server and get the response.send message like this:

IEnumerator IEUpload(string _url)
    {
        byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
        UnityWebRequest www = UnityWebRequest.Put(_url, myData);
        yield return www.Send();

        if (!string.IsNullOrEmpty(www.error))
        {
            appendCtrlDebugTx("fail to request..." + www.error);
            debugTx = "fail to request..." + www.error;
            Debug.Log(www.error);
        }
        else
        {
            appendCtrlDebugTx(www.downloadHandler.text);
            debugTx = www.downloadHandler.text;
            Debug.Log("Upload complete!");
        }
    }

but when i release project to a webgl and put it on a tomcate. i can only sent message to server but can not get response from server. and the error is unknown error.
my tomcat port is 8080 my http server port is 8081. i make sure correct address and port. but i can not get response. how to do?
thank you!

1 Like

up.
Same problem…

void Start ()
    {
        listener = new HttpListener ();
        listener.Prefixes.Add ("http://localhost:4444/");
        listener.Prefixes.Add ("http://127.0.0.1:4444/");
        listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
        listener.Start ();

        listenerThread = new Thread (startListener);
        listenerThread.Start ();
        Debug.Log ("Server Started");
    }

    private void startListener ()
    {
        while (true) {             
            var result = listener.BeginGetContext (ListenerCallback, listener);
            result.AsyncWaitHandle.WaitOne ();
        }
    }

…lead to:

SocketException: Success
  at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x00000] in <00000000000000000000000000000000>:0

Unity 2019.3.14f
WebGL Release build.