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!