You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've made a self-signed certificate to make https requests to my WebSocket server. However, I can't find any options for setting certificates on the Unity client end. Is that possible? Here is my current client-side code:
publicclassWebSockets:MonoBehaviour{publicSocketIOUnitysocket;privatestringserverUrlLink="wss://192.168.1.116:3000";privatevoidAwake(){
ServicePointManager.ServerCertificateValidationCallback =(sender,certificate,chain,sslPolicyErrors)=>{returntrue;// Supposed to accept all certificates, perhaps only works with UnityWebRequest?};}privatevoidStart(){varuri=new Uri(serverUrlLink);socket=new SocketIOUnity(
uri,new SocketIOOptions {Query=newDictionary<string,string>{{"token","UNITY"}},EIO=4,Transport= SocketIOClient.Transport.TransportProtocol.WebSocket,});
socket.JsonSerializer =new NewtonsoftJsonSerializer();///// reserved socketio events
socket.OnConnected +=(sender,e)=>{ Debug.Log("socket.OnConnected");};
socket.OnDisconnected +=(sender,e)=>{ Debug.Log("disconnect: "+e);};
socket.OnReconnectAttempt +=(sender,e)=>{ Debug.Log($"{DateTime.Now} Reconnecting: attempt = {e}");};////
Debug.Log("Connecting...");
socket.Connect();
socket.On("message", OnMessageReceived);
NativeInputController.s_Press +=OnPress;
NativeInputController.s_DownSwipe +=Disconnect;
Debug.Log(socket.ClientWebSocketProvider);
Debug.Log(socket.HttpClient);
Debug.Log(socket.Options.Auth);}voidDisconnect(){
socket.Disconnect();
socket.Dispose();}voidOnDestroy(){
socket.Disconnect();
socket.Dispose();}privatevoidOnPress(){
socket.EmitAsync("message","Hello, server!");
Debug.Log("press");}privatevoidOnMessageReceived(SocketIOResponseevt){
Debug.Log("Response received from server: "+ evt.ToString());}}
```
Whenever I run this code, the client keeps trying to connect to the server and the server responds by outputting "accepted" repeatedly. Not running with certificates, the code runs fine.
The text was updated successfully, but these errors were encountered:
I've made a self-signed certificate to make https requests to my WebSocket server. However, I can't find any options for setting certificates on the Unity client end. Is that possible? Here is my current client-side code:
The text was updated successfully, but these errors were encountered: